Pagini recente » Cod sursa (job #2355531) | Cod sursa (job #153729) | Cod sursa (job #510678) | Cod sursa (job #2776104) | Cod sursa (job #274761)
Cod sursa(job #274761)
#include <stdio.h>
#include <math.h>
#define nmax 50*1000+1
long int M, N, D[nmax], L[nmax], MAX;
int main()
{
long int i,j;
long int rez;
FILE *in, *ie;
in=fopen("orase.in","r");
fscanf(in,"%ld %ld",&M,&N);
for(i=0;i<N;i++)
{
fscanf(in,"%ld %ld\n",&D[i],&L[i]);
}
fclose(in);
for(i=0;i<N;i++)
for(j=0;j<N;j++)
{
rez=L[i]+L[j]+fabs(D[i]-D[j]);
if(rez>MAX)
MAX=rez;
}
ie=fopen("orase.out","w");
fprintf(ie,"%ld",MAX);
fclose(ie);
}