Pagini recente » Cod sursa (job #3142776) | Cod sursa (job #293323) | Cod sursa (job #1851507) | Cod sursa (job #2419429) | Cod sursa (job #2629070)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define int long long
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const ll inf = 2e9;
const ll mod = 998244353;
const int N = 6e6 + 11;
const int NMAX = 1e4 + 11;
const ll INF64 = 3e18 + 1;
const double eps = 1e-14;
const double PI = acos(-1);
ifstream in("ssm.in");
ofstream out("ssm.out");
int n, s[N], pos[N];
int32_t main(){
ios_base :: sync_with_stdio(0); in.tie(); out.tie();
//cout << setprecision(20) << fixed;
in >> n;
for(int i = 1, x; i <= n; i++){
in >> x;
if(s[i - 1] <= 0){
pos[i] = i;
s[i] = x;
}else{
pos[i] = pos[i - 1];
s[i] = s[i - 1] + x;
}
}
int ans = -2e9, l = 0, r = 0;
for(int i = 1; i <= n; i++){
if(s[i] > ans){
ans = s[i];
l = pos[i];
r = i;
}
}
out << ans << ' ' << l << ' ' << r;
}