Cod sursa(job #672704)
Utilizator | Data | 2 februarie 2012 22:24:31 | |
---|---|---|---|
Problema | Secventa 2 | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<fstream>
using namespace std;
int n,i,sc,st=1,smax,drmax,stmax,x;
int v[6000001];
int main()
{
ifstream f("secv2.in");
ofstream g("secv2.out");
f>>n;
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(sc>smax)
{
smax=sc;
stmax=st;
drmax=i;
}}
g<<stmax<<" "<<drmax<<" "<<smax;
return 0;
}