Pagini recente » Borderou de evaluare (job #2010037) | Cod sursa (job #560292) | Cod sursa (job #2505234) | Cod sursa (job #2232217) | Cod sursa (job #2553017)
#include <bits/stdc++.h>
const int BUFFER_SIZE = 1 << 17;
char buffer[BUFFER_SIZE];
int pos = BUFFER_SIZE;
inline char next() {
if (pos == BUFFER_SIZE) {
fread(buffer, 1, BUFFER_SIZE, stdin);
pos = 0;
}
return buffer[pos++];
}
inline int read() {
int x = 0, neg = 1;
char c = next();
if (c == '-') {
neg = -1;
}
while (!('0' <= c && c <= '9')) {
c = next();
}
while ('0' <= c && c <= '9') {
x = (x << 3) + (x << 1) + (c - '0');
c = next();
}
return x * neg;
}
int main() {
freopen("ssm.in", "r", stdin);
freopen("ssm.out", "w", stdout);
int n;
n = read();
int dp, init_pos, starting_pos, last_pos, sum = 0, max_sum = INT_MIN;
for (int i = 0 ; i < n ; ++i) {
dp = read();
if (sum >= 0) {
sum += dp;
} else {
sum = dp;
init_pos = i;
}
if (max_sum < sum) {
max_sum = sum;
starting_pos = init_pos;
last_pos = i;
}
}
++starting_pos;
++last_pos;
printf("%d %d %d\n", max_sum, starting_pos, last_pos);
return 0;
}