Cod sursa(job #143269)
Utilizator | Data | 26 februarie 2008 10:11:39 | |
---|---|---|---|
Problema | Operatii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <fstream.h>
int main(){
ifstream in("operatii.in");
ofstream out("operatii.out");
long long int n,sum=0,i;
long int nr,max;
in >>n;
max=0;
for(i=0;i<n;i++){
in >>nr;
if(nr>max)
max=nr;
if(max>0)
if(nr==0 || i==n-1){
sum=sum+max;
max=0;
}
}
out <<sum;
in.close();
out.close();
return 0;
}