Cod sursa(job #2251525)
| Utilizator | Data | 1 octombrie 2018 18:00:41 | |
|---|---|---|---|
| Problema | Orase | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream f("orase.in");
ofstream g("orase.out");
pair<int,int>v[50001];
int n,m;
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);
int ras=0;
int mx=v[n].first+v[n].second;
for(int i=n-1;i>=1;--i)
{
ras=max(ras,mx-v[i].first+v[i].second);
mx=max(mx,v[i].first+v[i].second);
}
g<<ras;
}
