Pagini recente » Cod sursa (job #811372) | Cod sursa (job #2453879) | Cod sursa (job #3142556) | Cod sursa (job #2413717) | Cod sursa (job #2870926)
#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;
}