Pagini recente » Cod sursa (job #1607392) | Cod sursa (job #155338) | Cod sursa (job #3224393) | Cod sursa (job #2728435) | Cod sursa (job #2307951)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main()
{
ifstream fin("stergeri.in");
ofstream fout("stergeri.out");
int n,m,k;
fin >> n >> m >> k;
vector<pair<int,int> > operatii;
for(int i = 0; i < m; i++)
{
pair<int, int> tm;
fin >> tm.first >> tm.second;
operatii.push_back(tm);
}
int poz = k;
for(int i = m-1; i >= 0; i--){
if(poz >= operatii[i].first)
poz += operatii[i].second - operatii[i].first+1;
}
fout << poz;
fin.close();
fout.close();
return 0;
}