Pagini recente » Cod sursa (job #2125778) | Cod sursa (job #1564751) | Cod sursa (job #1831186) | Cod sursa (job #2578742) | Cod sursa (job #3145993)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nmax 50005
#define MOD 666013
#define INF 1000000007
//#define fin cin
//#define fout cout
ifstream fin("secv2.in");
ofstream fout("secv2.out");
int n, k;
int a[nmax];
int main()
{
int i, j, maxi, x, y;
fin >> n >> k;
for (i = 1; i <= n; i++)
{
fin >> a[i];
a[i] += a[i - 1];
}
maxi = -INF;
for (i = 1; i <= n - 2; i++)
for (j = i + 2; j <= n; j++)
if (a[j] - a[i - 1] > maxi)
{
maxi = a[j] - a[i - 1];
x = i;
y = j;
}
fout << x << " " << y << " " << maxi << "\n";
fout.close();
fin.close();
return 0;
}