This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
#define all(a) a.begin(), a.end()
typedef long long ll;
const ll N = 2000004;
const ll mod = 1000 * 1000 * 1000 + 7;
const ll inf = 1000000000;
ll n, m, k, z, t, x, y, ans,a[N];
int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	x = a[0];
	ans = 1;
	for (int i = 1; i < n;)
	{
		
		int j = i;
		y = 0;
		while (i<n && y < x)
		{
			y += a[i];
			++i;
		}
		if (i >= n && y<x)
		{
			break;
		}
		ans++;
		while (x + a[j] < y - a[j])
		{
			y -= a[j];
			x += a[j];
			j++;
		}
		x = y;
	}
	cout << ans << endl;
	return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |