Submission #973328

#TimeUsernameProblemLanguageResultExecution timeMemory
973328MvKaioNizin (COCI16_nizin)C++17
100 / 100
46 ms6292 KiB
#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 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...