Cod sursa(job #1585278)
| Utilizator | Data | 30 ianuarie 2016 21:47:01 | |
|---|---|---|---|
| Problema | Orase | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <stdio.h>
int str[1000001];
int main()
{
int n, m, a, b, i, d, max;
FILE *fi=fopen("orase.in", "r"), *fo=fopen("orase.out", "w");
fscanf(fi, "%d%d", &m, &n);
for(i=0;i<n;i++){
fscanf(fi, "%d%d", &a, &b);
if(str[a]<b)
str[a]=b;
}
i=0;
while(str[i]==0)
i++;
d=str[i];
max=0;
for(i=i+1;i<=m;i++){
d++;
if(str[i]!=0){
if(d+str[i]>max)
max=d+str[i];
if(d<str[i])
d=str[i];
}
}
fprintf(fo, "%d", max);
fclose(fi);
fclose(fo);
return 0;
}
