Submission #510083

#TimeUsernameProblemLanguageResultExecution timeMemory
510083Rasoul006Nizin (COCI16_nizin)C++17
100 / 100
66 ms4208 KiB
#include <bits/stdc++.h> #define endl "\n" ; typedef long long ll ; using namespace std; int a[5555555]; ll n,l,r,ans; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; for (int i=0 ; i<n ; i++) { cin>>a[i]; } if (n==1) { cout<<0; return 0; } r = n-1; while (l<=r) { if (a[r]==a[l]) { r--; l++; } else if (a[r]<a[l]) { a[r-1]+=a[r]; r--; ans++; } else if (a[l]<a[r]) { a[l+1]+= a[l] ; l++; ans++; } } cout<<ans; 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...