Submission #1093789

#TimeUsernameProblemLanguageResultExecution timeMemory
1093789ramzialoulouNizin (COCI16_nizin)C++17
100 / 100
45 ms6408 KiB
#include <bits/stdc++.h> using namespace std; #ifdef Ramzi #include "debug.h" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 0 << "\n"; return 0; } int l = 0, r = n - 1; int ans = 0; while (l < r) { if (a[l] != a[r]) { if (a[l] < a[r]) { while (l < n && a[l] < a[r]) { a[l + 1] += a[l]; ++l; ++ans; } } else { while (r >= 0 && a[r] < a[l]) { a[r - 1] += a[r]; ++ans; --r; } } } else { ++l, --r; } } cout << 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...