Pagini recente » Cod sursa (job #1468218) | Cod sursa (job #3259776) | Cod sursa (job #543112) | Cod sursa (job #2214310) | Cod sursa (job #1309717)
#include<fstream>
#include<algorithm>
using namespace std;
ifstream in("orase.in");
ofstream out("orase.out");
struct point{
int d, l;
};
const int nmax = 50006;
int n, m, rasp, dmax, lmax;
point v[nmax];
int compar(point a, point b)
{
return a.d<b.d;
}
int main(){
int player_unu=0;
in>>m>>n;
for(int i = 1; i<=n; i++)
in>>v[i].d>>v[i].l;
sort(v + 1, v + n + 1, compar);
dmax = v[1].d;
for(int i = 1; i<=n; i++)
{
if(v[i].l + v[i].d - dmax + lmax>rasp)
{
rasp = v[i].l + v[i].d - dmax + lmax;
}
if(v[i].d - dmax + lmax<v[i].l)
{
dmax = v[i].d;
lmax = v[i].l;
}
}
out<<rasp<<'\n';
return player_unu;
}