Submission #973328

# Submission time Handle Problem Language Result Execution time Memory
973328 2024-05-01T18:34:41 Z MvKaio Nizin (COCI16_nizin) C++17
100 / 100
46 ms 6292 KB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
	fast_io;

	int n; cin >> n;
	vector<int> A(n); for (auto &x : A) cin >> x;

	ll hl = A[0], hr = A[n - 1], l = 0, r = n - 1, ans = 0;
	while (l <= r) {
		if (hl == hr) {
			l++; r--;
			if (l <= r) {
				hl = A[l];
				hr = A[r];
			}
		} else {
			ans++;
			if (l + 1 == r) break;

			if (hl < hr) {
				l++;
				hl += A[l];
			} else {
				r--;
				hr += A[r];
			}
		}
	}

	cout << ans << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 6 ms 860 KB Output is correct
3 Correct 5 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2396 KB Output is correct
2 Correct 18 ms 2908 KB Output is correct
3 Correct 22 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4952 KB Output is correct
2 Correct 34 ms 5208 KB Output is correct
3 Correct 39 ms 5752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 6228 KB Output is correct
2 Correct 43 ms 6292 KB Output is correct
3 Correct 46 ms 6228 KB Output is correct