Submission #83598

# Submission time Handle Problem Language Result Execution time Memory
83598 2018-11-09T12:58:02 Z luciocf Nizin (COCI16_nizin) C++14
100 / 100
208 ms 4540 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e6+10;

int num[maxn];

int main(void)
{
	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> num[i];

	int l = 1, r = n, ans = 0;
	ll somal = num[1], somar = num[n];

	while (true)
	{
		if (l >= r) break;

		if (somal < somar) somal += (ll)num[++l], ans++;
		else if (somar < somal) somar += (ll)num[--r], ans++;
		else somal = num[++l], somar = num[--r];
	}

	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 740 KB Output is correct
2 Correct 2 ms 740 KB Output is correct
3 Correct 2 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 832 KB Output is correct
2 Correct 20 ms 892 KB Output is correct
3 Correct 26 ms 1020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 1916 KB Output is correct
2 Correct 83 ms 2248 KB Output is correct
3 Correct 126 ms 2460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 183 ms 3596 KB Output is correct
2 Correct 182 ms 3748 KB Output is correct
3 Correct 168 ms 4092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 190 ms 4348 KB Output is correct
2 Correct 208 ms 4540 KB Output is correct
3 Correct 189 ms 4540 KB Output is correct