Submission #717309

#TimeUsernameProblemLanguageResultExecution timeMemory
717309Urvuk3Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms304 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int INF=1e9; const ll LINF=1e18; #define fi first #define se second #define pii pair<int,int> #define mid ((l+r)/2) #define sz(a) (int((a).size())) #define all(a) a.begin(),a.end() #define endl "\n" #define pb push_back void PRINT(int x) {cerr << x;} void PRINT(ll x) {cerr << x;} void PRINT(double x) {cerr << x;} void PRINT(char x) {cerr << '\'' << x << '\'';} void PRINT(string x) {cerr << '\"' << x << '\"';} void PRINT(bool x) {cerr << (x ? "true" : "false");} template<typename T,typename V> void PRINT(pair<T,V>& x){ cerr<<"{"; PRINT(x.fi); cerr<<","; PRINT(x.se); cerr<<"}"; } template<typename T> void PRINT(T &x){ int id=0; cerr<<"{"; for(auto _i:x){ cerr<<(id++ ? "," : ""); PRINT(_i); } cerr<<"}"; } void _PRINT(){ cerr<<"]\n"; } template<typename Head,typename... Tail> void _PRINT(Head h,Tail... t){ PRINT(h); if(sizeof...(t)) cerr<<", "; _PRINT(t...); } #define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x) long long delivery(int N, int K, int L, int p[]) { //Debug(N,K,L); vector<int> cw,acw; for(int i=0;i<N;i++){ if(p[i]>L/2) break; cw.pb(p[i]); } for(int i=N-1;i>=0;i--){ if(L-p[i]>L/2) break; acw.pb(L-p[i]); } vector<ll> scw(sz(cw)+1,0),sacw(sz(acw)+1,0); for(ll i=1;i<=sz(cw);i++){ if(i<=K) scw[i]=2*cw[i-1]; else scw[i]=scw[i-K]+2*cw[i-1]; } for(ll i=1;i<=sz(acw);i++){ if(i<=K) sacw[i]=2*acw[i-1]; else sacw[i]=sacw[i-K]+2*acw[i-1]; } //Debug(cw,acw); ll res=LINF; for(int ccw=0;ccw<=sz(cw);ccw++){ if(N-ccw<=K){ res=min(res,scw[ccw]+L); } else if(L-p[ccw-1+K+1]<=L/2){ res=min(res,scw[ccw]+L+sacw[N-ccw-K]); } if(L-p[ccw]<=L/2 || ccw==K){ res=min(res,scw[ccw]+sacw[N-ccw]); } } //Debug(res); return res; }
#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...