Pagini recente » Cod sursa (job #3156909) | Cod sursa (job #235186) | Cod sursa (job #1797421) | Cod sursa (job #3158686) | Cod sursa (job #3209528)
#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);
}