Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin ("ssm.in");
- ofstream fout ("ssm.out");
- int N, x, S, in1, in2, smax, u;
- int main() {
- fin >> N >> S;
- smax = S;
- in1 = in2 = 1;
- for (int i = 1; i < N; i++) {
- fin >> x;
- if (S < 0) {
- u = i;
- S = x;
- }
- else
- S += x;
- if (S > smax)
- smax = S, in1 = u + 1, in2 = i + 1;
- }
- fout << smax << ' ' << in1 << ' ' << in2 << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment