This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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[]) {
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]);
}
//Debug(cw,acw);
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];
}
ll res=LINF;
//Debug(scw);
//Debug(sacw);
for(int ccw=0;ccw<=sz(cw);ccw++){
if(N-ccw<=K){
res=min(res,scw[ccw]+L);
}
else{
res=min(res,scw[ccw]+L+sacw[N-ccw-K]);
}
}
//Debug(res);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |