Pagini recente » Cod sursa (job #2562934) | Cod sursa (job #1437532) | Cod sursa (job #3165884) | Cod sursa (job #2883868) | Cod sursa (job #627537)
Cod sursa(job #627537)
#include <stdio.h>
char*r;
int n,p,u,mx;
int next(){
bool neg=false;
int x=0;
while(*r!='-'&&(*r<'0'||*r>'9'))*r++;
if(*r=='-'){neg=true;*r++;};
while('0'<=*r&&*r<='9'){x=(x*10)+*r-'0';*r++;};
if(neg)return -x; else return x;
}
int main(){
int x,i,s,bst,p1=1;
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
scanf("%d\n",&n);
r=new char[n*12];
gets(r);
x=next();
p=1;u=1;mx=x;bst=x;
for(i=2;i<=n;i++){
x=next();
s=bst+x;
if(x>s){bst=x;p1=i;} else bst=s;
if(bst>mx){p=p1;u=i;mx=bst;} }
printf("%d %d %d\n",mx,p,u);
}