Cod sursa(job #1584151)
Utilizator | Data | 29 ianuarie 2016 18:59:14 | |
---|---|---|---|
Problema | Stergeri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include<fstream>
#include<stack>
#define mkp make_pair
using namespace std;
ifstream si("stergeri.in");
ofstream so("stergeri.out");
stack< pair<int,int> > s;
int main()
{
int n,m,k,i,a,b;
si>>n>>m>>k;
for(i=0;i<m;++i)
{
si>>a>>b;
s.push(mkp(a,b));
}
while(!s.empty())
{
a=s.top().first;
b=s.top().second;
s.pop();
if(a<=k)
k+=b-a+1;
}
so<<k<<'\n';
return 0;
}