Cod sursa(job #2307633)

Utilizator ardutgamerAndrei Bancila ardutgamer Data 25 decembrie 2018 10:11:43
Problema Orase Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <cstdio>
#include <vector>
#include <algorithm>
#define pb push_back

using namespace std;

int n , m;
struct blat{
int x,y;
blat(int a,int b)
{
    x = a;
    y = b;
}
};

vector<blat>v;

bool cmp(blat a,blat b)
{
    return a.x < b.x;
}

int main()
{
    freopen("orase.in","r",stdin);
    freopen("orase.out","w",stdout);
    scanf("%d%d",&n,&m);
    int a,b;
    int ma = 0;
    for(int i = 1 ; i <= m ; i++)
    {
        scanf("%d%d",&a,&b);
        blat temp(a,b);
        v.pb(temp);
    }
    sort(v.begin(),v.end(),cmp);
    for(int i = 0 ; i < v.size() ; i++)
        for(int j = 0 ; j <= i ; j++)
            ma = max(ma,v[i].y+v[j].y+v[i].x-v[j].x);
    printf("%d",ma);
    return 0;
}