제출 #469938

#제출 시각아이디문제언어결과실행 시간메모리
469938cpp219Hacker (BOI15_hac)C++14
0 / 100
1 ms332 KiB
#include<bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second #define debug(y) cout<<y,exit(0) using namespace std; typedef pair<ll,ll> LL; const ll N = 1e6 + 9; const ll mod = 998244353; ll n,a[N],pre[N],val[N],take,ans; ll cal(ll l,ll r){ //cout<<pre[r]<<" "<<pre[n] - pre[l - 1]; exit(0); if (l <= r) return pre[r] - pre[l - 1]; return pre[r] + pre[n] - pre[l - 1]; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".inp","r")){ freopen(task".inp","r",stdin); //freopen(task".out","w",stdout); } cin>>n; take = (n + 1)/2; for (ll i = 1;i <= n;i++) cin>>a[i],pre[i] = pre[i - 1] + a[i]; //cout<<cal(4,1)<<"x"; return 0; for (ll i = 1;i <= n;i++){ ll l = i,r = i + take - 1; if (r > n) r -= n; //cout<<l<<" "<<r<<" "<<cal(l,r)<<"\n"; val[i] = cal(l,r); } for (ll i = n + 1;i <= 2*n;i++) val[i] = val[i - n]; //for (ll i = 1;i <= n;i++) cout<<val[i]<<" "; return 0; deque<ll> dq; for (ll i = 1;i <= 2*n;i++){ while(!dq.empty() && val[i] <= val[dq.back()]) dq.pop_back(); while(!dq.empty() && i - dq.front() + 1 > take) dq.pop_front(); dq.push_back(i); ans = max(ans,val[dq.front()]); } cout<<ans; } /* stuff you should look for * int overflow,array bound * special cases (n = 1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */

컴파일 시 표준 에러 (stderr) 메시지

hac.cpp: In function 'int main()':
hac.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...