Submission #242531

#TimeUsernameProblemLanguageResultExecution timeMemory
242531NONAMENizin (COCI16_nizin)C++14
100 / 100
83 ms6392 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 1e6 + 500; int n, ans, a[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; int l = 0, r = n - 1; while (l < r) { if (a[l] == a[r]) { ++l, --r; continue; } if (a[l] < a[r]) { a[l + 1] += a[l]; ++l; ++ans; } else { a[r - 1] += a[r]; --r; ++ans; } } cout << ans << "\n"; }
#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...