Cod sursa(job #2251882)
| Utilizator | Data | 2 octombrie 2018 08:44:38 | |
|---|---|---|---|
| Problema | Orase | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <bits/stdc++.h>
#define Dim 50004
using namespace std;
ifstream f("orase.in");
ofstream g("orase.out");
long N,M;
long ans,maxim;
pair < long,long> V[Dim];
int main()
{
f>>M>>N;
for(int i=1;i<=N;i++)
f>>V[i].first>>V[i].second;
sort(V+1,V+N+1);
maxim=V[N].first+V[N].second;
for(int i=N-1;i>=1;i--)
{
ans=max(ans,maxim-V[i].first+V[i].second);
maxim=max(maxim,V[i].first+V[i].second);
}
g<<ans;
return 0;
}
