Cod sursa(job #1000514)

Utilizator poptibiPop Tiberiu poptibi Data 23 septembrie 2013 00:20:44
Problema Stergeri Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#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;
}