Cod sursa(job #1022962)
Utilizator | Data | 6 noiembrie 2013 11:30:05 | |
---|---|---|---|
Problema | Stergeri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.3 kb |
#include<fstream>
using namespace std;
ifstream f("stergeri.in");
ofstream g("stergeri.out");
int n,m,k,i,a[100001],b[100001];
int main()
{ f>>n>>m>>k;
for(i=1;i<=m;++i) f>>a[i]>>b[i];
for(i=m;i>=1;--i)
if(a[i]<=k) k+=b[i]-a[i]+1;
g<<k<<'\n';
g.close();
return 0;
}