Submission #738823

#TimeUsernameProblemLanguageResultExecution timeMemory
738823mzvNizin (COCI16_nizin)C++17
0 / 100
50 ms9932 KiB
#include <bits/stdc++.h> #define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define endl '\n' using namespace std; /* ------------------------ hi lol ------------------------ */ ll n,arr[1'000'001],le,ri,ans=0; int main() { ccd cin >> n; for (int i=1;i<=n;i++) { cin >> arr[i]; } le=1,ri=n; while (le<=ri) { if (arr[le]==arr[ri]) { le++; ri--; continue; } else if (le+1==ri-1) { ans++; break; } else if ((arr[le]+arr[le+1])==arr[ri]) { arr[le+1]+=arr[le]; ans++; le++; ri--; } else if ((arr[ri]+arr[ri-1])==arr[le]) { arr[ri-1]+=arr[ri]; ans++; le++; ri--; } else { if ((arr[ri]+arr[ri-1])>arr[le]+arr[le+1]) { arr[ri-1]+=arr[ri]; ri--; ans++; } else { arr[le+1]+=arr[le]; le++; ans++; } } } cout << ans << endl; }
#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...