Submission #875537

#TimeUsernameProblemLanguageResultExecution timeMemory
875537reginoxNizin (COCI16_nizin)C++17
100 / 100
50 ms10216 KiB
#include <bits/stdc++.h> #define ll long long #define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define sp << " " #define task "" using namespace std; const ll maxn = 1e6+1; ll n, a[maxn], l, r, cnt; int main(){ if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } faster cin >> n; for(ll i = 1; i <= n; i++) cin >> a[i]; l=1, r=n; while(l<=r){ while(l<=r && a[l]<a[r]){ a[l+1]+=a[l]; l++; cnt++; } if(a[l]==a[r]) l++,r--; while(l<=r && a[l]>a[r]){ a[r-1]+=a[r]; r--; cnt++; } if(a[l]==a[r]) l++,r--; } cout << cnt; return 0; }

Compilation message (stderr)

nizin.cpp: In function 'int main()':
nizin.cpp:11:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   freopen(task".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
nizin.cpp:12:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   freopen(task".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...