Submission #590772

#TimeUsernameProblemLanguageResultExecution timeMemory
590772MilosMilutinovicNizin (COCI16_nizin)C++14
100 / 100
54 ms6276 KiB
/** * author: wxhtzdy * created: 06.07.2022 12:52:22 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int ans = 0, L = 0, R = n - 1; long long s = 0, t = 0; while (L <= R) { if (s + a[L] <= t + a[R]) { s += a[L++]; } else { t += a[R--]; } if (s == t) { s = 0; t = 0; ans += 2; } if (L > R && s != t) { ans += 1; break; } } cout << n - ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...