Cod sursa(job #2812556)
Utilizator | Camburu Luca AswVwsA | Data | 4 decembrie 2021 18:09:48 |
---|---|---|---|
Problema | Orase | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
#include <algorithm>
#define ll long long
using namespace std;
const int NMAX = 100004;
ifstream cin("orase.in");
ofstream cout("orase.out");
struct hell
{
int d, l;
}v[NMAX];
bool cmp(hell a, hell b)
{
if (a.d != b.d)
return a.d < b.d;
return a.l < b.l;
}
int main()
{
int n, m, i, ans = 0;
cin >> m >> n;
for (i = 1; i <= n; i++)
cin >> v[i].d >> v[i].l;
sort(v + 1, v + n + 1, cmp);
for (i = 1; i < n; i++)
ans = max(ans, v[n].d - v[i].d + v[i].l + v[n].l);
cout << ans;
}