Pagini recente » Cod sursa (job #3351507) | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #2307882) | Cod sursa (job #2614736)
#include <bits/stdc++.h>
#define DAU ios::sync_with_stdio(false); fin.tie(0); fout.tie(0);
#define PLEC fin.close(); fout.close(); return 0;
using namespace std;
const string problem("ssm");
ifstream fin(problem + ".in");
ofstream fout(problem + ".out");
pair<int, int> p;
int n, x, st(1), dr;
long long curr, smax(-1e18);
int main() {
DAU
fin >> n;
for (int i = 1; i <= n; ++i) {
fin >> x;
curr += x;
if (curr > smax)
smax = curr, p = {st, i};
if (curr < 0)
curr = 0, st = i + 1;
}
fout << smax << ' ' << p.first << ' ' << p.second;
PLEC
}