Pagini recente » Clasament noaptea_burlacilor | Cod sursa (job #1491957) | Cod sursa (job #317321) | Cod sursa (job #753802) | Cod sursa (job #1863656)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
const int Inf = 0x3f3f3f3f;
int N;
int s, smax{-Inf};
int x;
int sc, dc, st, dr;
int main()
{
fin >> N;
for ( int i = 1; i <= N; ++i )
{
fin >> x;
if ( s + x > x )
s = s + x, dc++;
else
s = x, sc = dc = i;
if ( smax < s )
{
smax = s;
st = sc;
dr = dc;
}
}
fout << smax << ' ' << st << ' ' << dr << '\n';
fin.close();
fout.close();
return 0;
}