Cod sursa(job #1104232)

Utilizator sleepaholicNeculaescu Theodor sleepaholic Data 10 februarie 2014 16:47:33
Problema Stergeri Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>
 
using namespace std;
 
struct operatie
{
    int st,dr;
};
operatie op[100005];
 
int main()
{
    int N,M,K,st,dr,i;
    ifstream fin("stergeri.in");
    fin>>N>>M>>K;
    for(i=1;i<=M;++i)
        fin>>op[i].st>>op[i].dr;
    while(M)
    {
        st=op[M].st; dr=op[M].dr;
        if(dr<=K || st<=K)
            K=K+dr-st+1;
        M--;
    }
    ofstream fout("stergeri.out");
    fout<<K<<"\n";
    fout.close();
    return 0;
}