Cod sursa(job #880015)

Utilizator 5t3fristea stefan 5t3f Data 16 februarie 2013 10:09:17
Problema Operatii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
// operatii.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include "fstream"
using namespace std;
int main()
{
	ifstream f("operatii.in");
	ofstream g("operatii.out");
	int nr;
	f>>nr;
	long long elem;
	long long i,max=0,op=0;
	for(i=0;i<nr;i++)
	{
		f>>elem;
		if(elem>max)
			max=elem;
		if(elem==0)
		{
			op+=max;
			max=0;
		}
	}
	op+=max;
	g<<op;
	return 0;
}