Cod sursa(job #1479672)
| Utilizator | Data | 31 august 2015 21:25:52 | |
|---|---|---|---|
| Problema | Orase | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
vector<pair<int,int> > V;
int Max,aux;
int N,M,D,L;
int main()
{
freopen("orase.in","r",stdin);
freopen("orase.out","w",stdout);
scanf("%d%d",&M,&N);
for(int i=1;i<=N;i++)
{
scanf("%d%d",&D,&L);
V.push_back(make_pair(D,L));
}
sort(V.begin(),V.end());
for(auto it:V)
{
Max=max(Max,it.first+it.second+aux);
aux=max(aux,it.second-it.first);
}
printf("%d",Max);
}
