이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i<b; ++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<":"<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif
vector<ll>get(vector<int> &a, int K) {
sort(ALL(a));
vector<ll>dp(SZ(a)+1);
REP1(i, SZ(a)) {
dp[i] = a[i-1]*2 + (i-K>=0?dp[i-K]:0);
}
return dp;
}
long long delivery(signed N, signed K, signed L, signed p[]) {
vector<int>A, B;
REP(i,N) {
if(p[i] == 0)continue;
if(p[i] <= L/2) {
A.pb(p[i]);
}else{
B.pb(L-p[i]);
}
}
vector<ll>da = get(A,K), db = get(B,K);
ll re = da.back() +db.back();
for(int tka = 1; tka <K; ++tka) {
int tkb = K - tka;
if(tka <= SZ(A) && tkb <= SZ(B)) {
ll hi = L + da[SZ(da) - tka-1] + db[SZ(db) - tkb - 1];
bug(tka, hi);
MN(re, hi);
}
}
bug(re);
return re;
}
# | 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... |