제출 #1270623

#제출 시각아이디문제언어결과실행 시간메모리
1270623raymoo_Hacker (BOI15_hac)C++17
100 / 100
294 ms188296 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define umap unordered_map #define prq priority_queue #define vect vector #define rs resize #define bend(v) v.begin(),v.end() #define pob pop_back #define pof pop_front #define lwb lower_bound #define upb upper_bound #define pii pair<int,int> #define nextl cout << '\n' #define el '\n' #define deb cout<<"\nok\n";return #define ll long long #define int long long #define dbl long double #define popcnt __builtin_popcount #define ctz __builtin_ctz #define FILE "ellencute" const ll INF=902337203695775807, N=2e5+69, MOD=1e9+7; void ffopen(){ if(fopen(FILE".inp", "r")){ freopen(FILE".inp", "r", stdin); freopen(FILE".out", "w", stdout); }else if(fopen("ellencute.inp", "r")){ freopen("ellencute.inp", "r", stdin); freopen("ellencute.out", "w", stdout); } } int pm(int a,const int b=1e9+7){return ((a%b)+b)%b;} int sq(int x){return x*x;} ll __lcm(ll a, ll b, const ll lim=LLONG_MAX){ if(a == -1 || b == -1)return -1; ll g = __gcd(a,b); if(b/g > lim/a)return -1; return (a/g)*b; } int lg2(int i) { return i ? __builtin_clzll(1) - __builtin_clzll(i) : -1; } int spt[1000005][21]; void sol(){ int n; cin >> n; int a[n*2], pfs[n*2], g[n*2]; for(int i=0;n>i;i++){ cin >> a[i]; a[i+n] = a[i]; } partial_sum(a, a+n*2, pfs); auto gs = [&](int l, int r){ if(l > r) return pfs[r] + pfs[n-1] - pfs[l-1]; return pfs[r] - (l?pfs[l-1]:0); }; int s = (n+1)/2, ans = -INF; for(int i=0;n*2>i;i++) g[i] = spt[i][0] = gs(i, (i+s-1)%(2*n)); for(int b=1;21>b;b++){ for(int i=0;n*2>i+(1<<(b-1));i++) spt[i][b] = min(spt[i][b-1], spt[i+(1<<(b-1))][b-1]); } auto get = [&](int l, int r){ int b = lg2(r-l+1); return min(spt[l][b], spt[r-(1<<b)+1][b]); }; // ans = max(ans, ); for(int j=s-1;n+s-1>j;j++){ // cout << i << ' ' << min(gs(i, (i+s-1)%n), gs(pm(i-s+1, n), i)) << el; // while(dq.size() && dq.front()+s-1 < j) dq.pof(); // // if(j==2) cout << dq.size() << el; // while(dq.size() && g[dq.back()] >= g[j]) dq.pob(); // // if(j == 1) cout << fumo << ' ' << gs(0) << el; // // if(12 == fumo) cout << j << ' ' << gs(0, 0+s-1) << el; // cout << j << ' ' << g[dq.back()] << el; ans = max(ans, get(j-s+1, j)); } cout << ans; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ffopen(); int t=1; //cin >> t; while(t--)sol(); } /* ...-%%%%%%%%%%%... .:**#%=%%%%%+........-%%%%. . .%%%%%%=-..%#. .#%%. %%%+.. .: *%%. .%%. :. :%%%%%:. .%%. ... .: :: .=%%%. ..%%. #%#:%. : :.. =%%. %%+..: .%*::::%-::::::-::::::.. .:-%%%%. .*%%.. .%# :.%:::::::%%%%%%%%%%%%%+...%%%+::::%#. .%%. .%%. ..:.%=::::*%#***#%::::::::%%%%=:::::::%%. .%%. =%%%...-%%%:::*%********%:::%%%****%::::::::%% .%- .%::::%%***%=:%%**********%%********%:::::::=%-:. .%.. #%:::%#*****%%**********************%:::+%%%*%%-.: .::..%%. .%%::%%*****==**==*****#************#%%%%#******%%..::::.. .%%. .%%#%+%%***************##*+=+*==********************%%.:. .%% .%%***%%****************#**==**==******==**+=+********%%%%%%%%% %%. .#%#*********************%%**************++************%%::::::%* .%%%. .%%***************#*****%%%****************************%%::::::%% .-%%%. .#%***************#****%%--%*********%*****************%#::::-%%%%%%%%%%. .%%**************#**%%%----%********%%**************#***#%%%#**%#******%* .%%**************#%%%--.....%%*******%%**************#**********#%******%%. .%%*************%%...........%%******%-%*************#***********%%*****%%. .%%*************%%...%%%%%.....%%%%%%%.=%%%%%%%%##****#****##::::+%%*****%# .%%************%%...%. %%.................%%%%-.....%*****#*****%%*****%% .#%#*#****#****%%:::%- %%.................%. #-....%*****#*#####%#****%%. .%%##****%%%**%%:::::##...................%= .%+:::%#*****#:####*%%****%%. .+%%#**%%.#%%%%::::::........###+.:*##-....%%%:::::%*****##******%%****%%- ..%%*%%.......:::.......##..#*...#+..#*....:::::%******#*****##%%*****%%. .%%%%%................#-##=--##+-+###-#....:::%******#:###*::%%#*****%%. .%%****%%..............#----------------=*...#%#****##**##::#**%%*******%%. .%%%%%*=+%%*...........#-----------------#.....#%%%%%%+:##*##:*%%*******%%%. ..:*%====%%%%........#-----------------#:.........%#********%%*****%%%%%%. .%%=======*%%%%%%%.%%+----#-%------%%#.......%%%%::::::::%%==***#%###%%. ..%%=============+%%-:#%%%%-::%%%%%%::%%%%%%%%%=%%*******%%=====**%%###%%.. -%%%%%%%%%%%%%%%%+%.%+:+%::%::::%::%:::%%#%... .%%******%%%========#%####%%. .%%++#############%%# ..%%.**%%#%%%%%%%#%***%. :%%*****%%%=+%%%%%%%%%%#####%%. .%%++++*############*++% .%************#****%. #%*%%%%+++%%%%###############%%. .+%%%%%%%%%%####+##########*+++++%%. .%**#**********#****% %%**%%%++++###################%: =%%%%######################++++++++%%*%.-%%#***********#****% .%****%%+++++###################%% .%%%#######################*%%%%%%%%.%%*#%+%###################%.%%***%%%+++++###################%% *%%######################+#%%++++++%*. =%*%. .:%%%%########%%%%%%%%%#*#%.%%++#####################%% .%%%#####################%%%%%+++++++%- %*#%%. .%%%*++++++*%%%....%%#####################%%* %%######%%%%%#%%%%%######%%.%*+++++++%. %****#. .%%+++*+++++*++%%...=%%###################%%%. %%%%%%%%#-=##%...%%######%%.%%+++++++%%..*%***#%%%%%. ..%+++++++++++++++%%...%%##################%%%. .%:. .#%#####%%.%%+++++++++%. %*********%%%%%++++++++++++++++%%...%%##############%%%%.. :%#####%% .%%+++++++%% .%%**********%%++++++++++++++++%%.....%#########%%%%%% . *%#####%%. .%%+++++++%%:. .%%********%%++++++++++++++++%%....%%%%%%%%%%%%*.. .%%##%%% .%%*+++++++%%. ..#%%%#****%%+++++++++++++++%%%%%% . ..... %%#%%%. .:%%%%%%%%%%%...-%. ......%%+++++++++++++%%. ..%%%. ... .%%%#%%%=:#%%%%%%%%*++++++%%%# .-%%+. ... .%%%%%%%:. */

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

hac.cpp: In function 'void ffopen()':
hac.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(FILE".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(FILE".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen("ellencute.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen("ellencute.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...