Cod sursa(job #3253149)
Utilizator | Data | 1 noiembrie 2024 18:20:15 | |
---|---|---|---|
Problema | Stergeri | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("stergeri.in");
ofstream fout("stergeri.out");
long long n,m,x,y,i,a,b,k,h,j;
int main()
{
fin>>n>>m>>k;
for(i=1;i<=m;i++)
{
fin>>a>>b;
if(i==1)
{
x=a;
y=b;
}
else
{
j=0;
while(h<=b)
{
j++;
if(j<x || j>y)
h++;
}
if(a<x)
x=a;
if(j>y)
y=j;
}
}
if(k>=x && k<=y)
fout<<y+x-1;
return 0;
}