Submission #912462

#TimeUsernameProblemLanguageResultExecution timeMemory
912462NeosNizin (COCI16_nizin)C++14
100 / 100
49 ms6264 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int n, a[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int l = 1, r = n, cnt = 0; for (; l < r; ) { if (a[l] == a[r]) { l++; r--; // (l + 1, r - 1) } else { if (a[l] > a[r]) { a[r - 1] += a[r]; r--; // (l, r - 1) cnt++; } else { a[l + 1] += a[l]; l++; // (l + 1, r - 1) cnt++; } } } cout << cnt; 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...