Submission #95558

#TimeUsernameProblemLanguageResultExecution timeMemory
95558oolimryNizin (COCI16_nizin)C++14
100 / 100
86 ms10232 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; //freopen("i.txt","r",stdin); scanf("%d",&n); long long arr[n]; for(int i = 0;i < n;i++){ scanf("%lld",&arr[i]); } int lindex = 0; long long lsum = arr[0]; int rindex = n-1; long long rsum = arr[n-1]; int steps = 0; while(lindex < rindex){ //printf("%d %d\n",lindex,rindex); if(lsum == rsum){ lindex++; rindex--; rsum = arr[rindex]; lsum = arr[lindex]; } else if(lsum > rsum){ rindex--; rsum += arr[rindex]; steps++; } else{ lindex++; lsum += arr[lindex]; steps++; } } printf("%d",steps); for(int i = 0;i < n;i++){ //printf("%lld ",arr[i]); } return 0; }

Compilation message (stderr)

nizin.cpp: In function 'int main()':
nizin.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
nizin.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&arr[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...