Submission #43361

#TimeUsernameProblemLanguageResultExecution timeMemory
43361HassoonyNizin (COCI16_nizin)C++14
0 / 100
103 ms4420 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX=1e6+9; int n,a[MX]; int main(){ scanf("%d",&n); for(int i=0;i<n;i++)scanf("%d",&a[i]); int p1=0,p2=n-1,ans=0; ll sum=0; while(p1<p2){ if(sum+a[p1]-a[p2]==0){ ++p1; --p2; sum=0; continue; } if(sum+a[p1]<sum-a[p2]){ sum+=a[p1++]; ans++; } else{ sum-=a[p2--]; ans++; } } if(n==1){ cout<<0<<endl; return 0; } if(sum!=0)ans++; cout<<ans<<endl; }

Compilation message (stderr)

nizin.cpp: In function 'int main()':
nizin.cpp:8:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
nizin.cpp:9:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%d",&a[i]);
                                          ^
#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...