Submission #1093779

#TimeUsernameProblemLanguageResultExecution timeMemory
1093779ramzialoulouNizin (COCI16_nizin)C++17
0 / 100
36 ms4188 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; } if (n == 2) { cout << (a[0] == a[1] ? 0 : 1) << "\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]) { int sum = 0; while (l < n && sum < a[r]) { sum += a[l++]; ++ans; } a[l] = sum; } else { int sum = 0; while (r >= 0 && sum < a[l]) { sum += a[r--]; ++ans; } a[r] = sum; } --ans; } 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...