Pagini recente » Cod sursa (job #1815596) | Cod sursa (job #1105643) | Cod sursa (job #1054853) | Cod sursa (job #2137025) | Cod sursa (job #1129068)
#include <cstdio>
#include <stack>
using namespace std;
stack<int> op_store;
int main()
{
freopen("stergeri.in", "r", stdin);
freopen("stergeri.out", "w", stdout);
int k, x, y, n, m;
scanf("%d %d %d", &n, &m, &k);
for(int i=1; i<=m; i++)
{
scanf("%d %d", &x, &y);
op_store.push(x);
op_store.push(y);
}
while(op_store.size()!=0)
{
y=op_store.top();
op_store.pop();
x=op_store.top();
op_store.pop();
if(x <= k)
{
k+= y - x + 1;
}
}
printf("%d",k);
}