Pagini recente » Cod sursa (job #3214815) | Borderou de evaluare (job #1562304) | Cod sursa (job #83857) | Cod sursa (job #8643) | Cod sursa (job #246274)
Cod sursa(job #246274)
#include<iostream.h>
#include<fstream.h>
int main()
{ unsigned long n,x,y,k,m,i,x1,y1;
fstream f("stergeri.in", ios::in);
fstream g("stergeri.out", ios::out);
f>>n;
f>>m>>k;
f>>x>>y;
if(k>=x){ k=k+(y-x)+1;}
for(i=2;i<=m;i++){
x1=x;y1=y;
f>> x; f>>y;
if(k>=x+(y1-x1)+1){k=k+(y-x)+1;}
}
g<<k;
g.close();
f.close();
return 0;}