Cod sursa(job #3209528)

Utilizator MihneaStoicaMihnea Teodor Stoica MihneaStoica Data 2 martie 2024 18:29:56
Problema Stergeri Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.42 kb
#include <bits/stdc++.h>

#ifdef LOCAL
#include <Windows.h>
#include <thread>
#endif

using namespace std;

struct io_info
{
    pair<string, string> io;
    bool fastio;
};

namespace IO_props
{
bool multiple_cases = 0;
io_info online = {{"stergeri.in", "stergeri.out"}, 1};
io_info local  = {{"", ""}, 1};
}

//
#define int int64_t
//*/

bool cmp(pair<int, int> a, pair<int, int> b)
{
    return a.second < b.second;
}

class solve
{
public: solve()
    {
        int n, k, q; cin >> n >> k >> q;

        vector<pair<int, int>> v(k + 1);

        for (int i = 1; i <= k; i ++) cin >> v[i].first >> v[i].second;

        for (int i = k; i >= 1; i --)
        {
            if (q >= v[i].first)
            {
                q += v[i].second - v[i].first + 1;
            }
        }

        cout << q << '\n';
    }
};

/**



*/

void setio(io_info f);

int32_t main()
{
#ifndef LOCAL
    setio(IO_props::online);
#else
    setio(IO_props::local);
#endif

    int t = 1;
    if (IO_props::multiple_cases == 1)  cin >> t;

    while (t --)
        solve();

    return 0;
}

void setio(io_info f)
{
    if (f.fastio)
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }
    if (!f.io.first.empty())   freopen(f.io.first.c_str(), "r", stdin);
    if (!f.io.second.empty())  freopen(f.io.second.c_str(), "w", stdout);
}