Pagini recente » Istoria paginii utilizator/hannahcris | Diferente pentru utilizator/andrei-27 intre reviziile 20 si 21 | Sandbox | Diferente pentru utilizator/cosmin79 intre reviziile 94 si 21 | 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;
}