Cod sursa(job #880036)

Utilizator 5t3fristea stefan 5t3f Data 16 februarie 2013 10:40:23
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 x=0,e1,e2;
	long long i,max,op=0;
	f>>e1;
	for(i=1;i<nr;i++)
	{
		f>>e2;
		if(e2>e1)
			max=e2;
		else
		{
			op+=max;
			max=0;
		}
		e1=e2;
	}
	op+=max;
	g<<op;
	return 0;
}