Pagini recente » Atasamentele paginii Profil Alexandraaaa | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #3309774) | Cod sursa (job #3320605)
#include <fstream>
using namespace std;
ifstream fin("stergeri.in");
ofstream fout("stergeri.out");
#define N 100005
struct interval
{
long long x, y;
}a[N];
long long n, m, k;
void citire()
{
fin >> n >> m >> k;
for(int i = 1; i <= m; i++)
fin >> a[i].x >> a[i].y;
}
int main()
{
citire();
for(int i = m; i >= 1; i--)
{
long long lg = a[i].y - a[i].x + 1;
if(k >= a[i].x)
k += lg;
}
fout << k;
return 0;
}