Submission #98356

#TimeUsernameProblemLanguageResultExecution timeMemory
98356dalgerokNizin (COCI16_nizin)C++17
100 / 100
84 ms10300 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n; long long a[N]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } int l = 1, r = n, ans = 0; while(l <= r){ if(a[l] == a[r]){ l += 1; r -= 1; } else if(a[l] < a[r]){ a[l + 1] += a[l]; l += 1; ans += 1; } else{ a[r - 1] += a[r]; r -= 1; ans += 1; } } cout << ans; }
#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...