Cod sursa(job #175830)

Utilizator rethosPaicu Alexandru rethos Data 10 aprilie 2008 14:34:10
Problema Orase Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <ctime>
#include <cstdio>
#include <stdlib.h>
#define abs(x) (x>0?x:-x)
#define Tmax 0.19
#define NM 50001
using namespace std;
int m,n;
int max;
int l[NM],d[NM];
int main()
{clock_t t=clock()+Tmax*CLOCKS_PER_SEC;
 srand(time(NULL));
 freopen("orase.in","r",stdin);
 freopen("orase.out","w",stdout);
 scanf("%d %d",&m,&n);
 int i,j;
 for (i=1;i<=n;i++) scanf("%d %d",&d[i],&l[i]);
 while (clock()<=t)
   {i=rand()%n+1;
    j=rand()%n+1;
    if (i!=j&&(l[i]+l[j]+abs(d[i]-d[j])>max)) max=l[i]+l[j]+abs(d[i]-d[j]);
   }
 printf("%d",max);
 return 0;
}