Cod sursa(job #2870926)

Utilizator Dragono63Stanciu Rares Stefan Dragono63 Data 12 martie 2022 18:32:52
Problema Stergeri Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <bits/stdc++.h>
#define MMAX 100005

using namespace std;

/*******************************/
// INPUT / OUTPUT

ifstream f("stergeri.in");
ofstream g("stergeri.out");
/*******************************/
/// GLOBAL DECLARATIONS

int N, M, K;
int st[MMAX], dr[MMAX];
/*******************************/
/// FUNCTIONS

void ReadInput();
void Solution();
void Output();
/*******************************/
///-------------------------------------
inline void ReadInput()
{
    f >> N >> M >> K;

    for (int i = 1 ; i <= M ; ++ i)
    {
        f >> st[i] >> dr[i];
    }
}
///-------------------------------------
inline void Solution()
{
    for (int i = M ; i >= 1 ; -- i)
    {
        if (K >= st[i])
        {
            K += (dr[i] - st[i] + 1);
        }
    }
}
///-------------------------------------
inline void Output()
{
    g << K;
}
///-------------------------------------
int main()
{
    ReadInput();
    Solution();
    Output();
    return 0;
}