Cod sursa(job #672710)

Utilizator loredanacosteaCostea Loredana loredanacostea Data 2 februarie 2012 22:33:19
Problema Secventa 2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<fstream>
using namespace std;
int n,i,sc,st=1,smax,drmax,stmax,x,j;
int v[6000001];
int main()
{
	ifstream f("secv2.in");
	ofstream g("secv2.out");
	f>>n>>j;
	for(i=1;i<=n;i++)
		f>>x;
	for(i=1;i<=n;i++)
	{
		if(sc<=0)
		{
			st=i;
			sc=x;
		}
		else
			sc=sc+x;
		if(smax<sc)
		{
			smax=sc;
			stmax=st;
			drmax=i;
		}}
		g<<stmax<<" "<<drmax<<" "<<smax;
		return 0;
}