Cod sursa(job #1732355)

Utilizator andreey_047Andrei Maxim andreey_047 Data 21 iulie 2016 15:29:04
Problema Stergeri Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <bits/stdc++.h>

using namespace std;

const int nmax = 100005;

struct el{
 int x,y;
}a[nmax];

int N,M,K;

int main(){
   ifstream f("stergeri.in");
   ofstream g("stergeri.out");

   int i;
   f >> N >> M >> K;
   for(i = 1; i <= M; ++i)
      f >> a[i].x >> a[i].y;
   f.close();
   for(i = M; i; --i){
     if(K < a[i].x)continue;
     K+=(a[i].y-a[i].x+1);
   }
   g << K << '\n';
   g.close();
    return 0;
}