Submission #1270581

#TimeUsernameProblemLanguageResultExecution timeMemory
1270581nathan4690Hacker (BOI15_hac)C++20
100 / 100
227 ms35672 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define f1(i,n) for(int i=1;i<=n;i++) #define __file_name "" using namespace std; const ll maxn = 2e6+5, inf=1e18; ll n, a[maxn], pf[maxn], cnt, ans; multiset<ll> S; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if(fopen(__file_name ".inp", "r")){ freopen(__file_name ".inp","r",stdin); freopen(__file_name ".out","w",stdout); } // code here cin >> n; f1(i,n) cin >> a[i]; cnt = (n + 1) / 2; for(int i=n+1;i<=3*n;i++) a[i] = a[i - n]; f1(i, 3*n) pf[i] = pf[i-1] + a[i]; for(int i=n+1;i<=n+cnt;i++){ S.insert(pf[i] - pf[i - cnt]); } ans = *S.begin(); for(int i=n+2;i<=2*n;i++){ S.erase(S.find(pf[i-1] - pf[i - cnt - 1])); S.insert(pf[i + cnt - 1] - pf[i - 1]); ans = max(ans, *S.begin()); // cout << S.size() << '\n'; } cout << ans; return 0; }

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(__file_name ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(__file_name ".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...