Pagini recente » Cod sursa (job #1611754) | Cod sursa (job #2233817) | Cod sursa (job #279036) | Cod sursa (job #1914318) | Cod sursa (job #1774421)
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *fin, *fout;
int n, m, i, d, l, ds, dsmax, dd, ddmax;
fin = fopen("orase.in", "r");
fscanf(fin, "%d%d", &n, &m);
dsmax = 0;
ddmax = 0;
for (i = 0; i < n; i++){
fscanf(fin, "%d%d", &d, &l);
if (d>0){
ds = d+l;
if (dsmax<ds)
dsmax = ds;
}
if (d<n){
dd = d+l;
if (ddmax<dd)
ddmax = dd;
}
}
fclose(fin);
fout = fopen ("orase.out", "w");
fprintf(fout, "%d", dsmax + ddmax - m);
fclose(fout);
return 0;
}