Pagini recente » Cod sursa (job #2764486) | Cod sursa (job #576070) | Cod sursa (job #2970570) | album2 | Cod sursa (job #2323866)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
using namespace std;
ifstream f("stergeri.in");
ofstream g("stergeri.out");
int n,m,k;
pair <int,int>a[100002];
int main()
{
int i;
f>>n>>m>>k;
for(i=1;i<=m;i++)
f>>a[i].first>>a[i].second;
int x,y;
for(i=m;i>=1;i--)
{
x = a[i].first;
y = a[i].second;
if(k >= x)
k += y-x+1;
}
g<<k<<"\n";
return 0;
}