Pagini recente » Cod sursa (job #1505374) | Cod sursa (job #2711214) | Cod sursa (job #2222539) | Cod sursa (job #110092) | Cod sursa (job #580191)
Cod sursa(job #580191)
#include<fstream>
#define INF (1 << 30)
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int N,S,i,Smax,p,u;
int x,Pmax,Umax;
int main () {
f >> N;
S = Smax = -INF;
for ( i = 1 ; i <= N ; ++i ){
f >> x;
if ( S + x >= x ){
++u; S = S + x;
}
else{
p = u = i; S = x;
}
if ( S > Smax ){
Smax = S; Pmax = p; Umax = u;
}
}
g << Smax << " " << Pmax << " " << Umax;
f.close();
g.close();
return 0;
}