제출 #441317

#제출 시각아이디문제언어결과실행 시간메모리
441317julian33선물상자 (IOI15_boxes)C++14
10 / 100
3 ms204 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} ll solve(int positions[],int N,int K,int L){ ll ans=0; vector<ll> pref(N),suff(N); int zero=1; for(int i=0;i<N;i++){ if(positions[i]) zero=0; if(i<K){ if(zero) pref[i]=0; else pref[i]=min(2*positions[i],L); } else{ if(zero) pref[i]=0; else if(positions[i]==0) pref[i]=pref[i/K*K-1]+L; else pref[i]=pref[i/K*K-1]+min(2*positions[i],L); } } zero=1; for(int i=N-1;i>=0;i--){ if(positions[i]) zero=0; if(N-i-1<K){ if(zero) suff[i]=0; else suff[i]=min(2*(L-positions[i]),L); } else{ if(zero) suff[i]=0; else suff[i]=suff[N-1-(N-i-1)/K*K+1]+min(2*(L-positions[i]),L); } } ans=min(pref[N-1],suff[0]); for(int i=0;i<N-1;i++){ mina(ans,pref[i]+suff[i+1]); } return ans; } ll delivery(int N, int K, int L, int positions[]){ ll ans=solve(positions,N,K,L); while(positions[0]==0){ rotate(positions,positions+1,positions+N); mina(ans,solve(positions,N,K,L)); } return ans; }
#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...