Submission #631548

#TimeUsernameProblemLanguageResultExecution timeMemory
631548dozerNizin (COCI16_nizin)C++14
100 / 100
76 ms8092 KiB
#include <bits/stdc++.h> using namespace std; #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define pb push_back #define pii pair<int, int> #define st first #define nd second #define sp " " #define endl "\n" #define N 1000005 #define modulo 1000000007 #define int long long int arr[N]; int32_t main() { fastio(); int n; cin>>n; for (int i = 1; i <= n; i++) cin>>arr[i]; int l = 0, r = n + 1, sl = 0, sr = 0, ans = 0; int steps = 0; while(l < r) { //cout<<l<<sp<<r<<endl; while(sl != sr && l < r) { while(sl < sr && l < r) { //cout<<l<<sp<<r<<sp<<sl<<sp<<sr<<endl; l++; sl += arr[l]; ans++; } while(sr < sl && l < r) { //cout<<l<<sp<<r<<sp<<sl<<sp<<sr<<endl; r--; sr += arr[r]; ans++; } } l++, r--; sl = arr[l], sr = arr[r]; } cout<<ans<<endl; cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n"; }

Compilation message (stderr)

nizin.cpp: In function 'int32_t main()':
nizin.cpp:27:6: warning: unused variable 'steps' [-Wunused-variable]
   27 |  int steps = 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...