Cod sursa(job #3123860)

Utilizator Mihai_OctMihai Octavian Mihai_Oct Data 25 aprilie 2023 19:08:39
Problema Stergeri Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

ifstream fin("stergeri.in");
ofstream fout("stergeri.out");
int n, m, k, i;
pair<int, int> a[100002];

int main()  {
    fin >> n >> m >> k;
    for(i = 1; i <= m; i++) fin >> a[i].x >> a[i].y;
    for(i = m; i >= 1; i--) {
        if(k >= a[i].x) k += a[i].y - a[i].x + 1;
    }
    fout << k;

    return 0;
}