Cod sursa(job #2773101)

Utilizator nubnubMeh Neh nubnub Data 4 septembrie 2021 18:35:14
Problema Stergeri Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>
#define nmax 100100
using namespace std;

int N,M,K,A[nmax],B[nmax];

void solve() {

    for(int i=M;i;i--)
        if(A[i]<=K)
            K+=B[i]-A[i]+1;

}
void read() {

    ifstream in("stergeri.in");

    in>>N>>M>>K;
    for(int i=1;i<=M;i++)
        in>>A[i]>>B[i];

    in.close();

}
void write() {

    ofstream out("stergeri.out");
    out<<K<<'\n';
    out.close();

}
int main() {

    read();
    solve();
    write();

    return 0;

}