Pagini recente » Cod sursa (job #2717035) | Cod sursa (job #178717) | Cod sursa (job #2551825) | Cod sursa (job #2987809) | Cod sursa (job #1794644)
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,m,l,d,i;
int maxst = 0;
int maxdr = 0;
FILE * fp;
fp = fopen("orase.in","r");
fscanf(fp,"%i",&m);
fscanf(fp,"%i",&n);
for(i = 0;i<n;i++)
{
fscanf(fp,"%d",&d);
fscanf(fp,"%d",&l);
if(d+l > maxst)
{
maxst = d+l;
}
if(m-d+l>maxdr)
{
maxdr=m-d+l;
}
}
fclose(fp);
fp = fopen("orase.out","w");
fprintf(fp,"%i",maxst+maxdr-m);
fclose(fp);
return 0;
}