Cod sursa(job #2292413)
Utilizator | Tudor Cosmin Oanea bananamandaone | Data | 29 noiembrie 2018 15:23:51 |
---|---|---|---|
Problema | Stergeri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("stergeri.in");
ofstream fout("stergeri.out");
int n,m,k;
struct Pereche
{
int x,y;
};
Pereche a[100003];
void Citire()
{
int i;
fin>>n>>m>>k;
for(i=1;i<=m;i++)
fin>>a[i].x>>a[i].y;
}
void Rezolvare()
{
int i,x,y;
for(i=m;i>=1;i--)
{
x = a[i].x;
y = a[i].y;
if(k >= x)
k += y-x+1;
}
fout<<k<<"\n";
}
int main()
{
Citire();
Rezolvare();
fin.close();
fout.close();
return 0;
}