Pagini recente » Cod sursa (job #2120338) | Cod sursa (job #1914961) | Cod sursa (job #225685) | Cod sursa (job #1652286) | Cod sursa (job #1000514)
#include <cstdio>
#include <algorithm>
using namespace std;
const int NMAX = 100005;
int N, M, K, Left[NMAX], Right[NMAX];
int main()
{
freopen("stergeri.in", "r", stdin);
freopen("stergeri.out", "w", stdout);
scanf("%i %i %i", &N, &M, &K);
for(int i = 1; i <= M; ++ i)
scanf("%i %i", &Left[i], &Right[i]);
for(int i = M; i; -- i)
if(Left[i] <= K)
K += Right[i] - Left[i] + 1;
printf("%i\n", K);
return 0;
}