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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e5 + 5;
ll dp[10000007];
ll delivery(int n, int k, int l, int position[]){
for (int i = 1; i <= n; i++){
dp[i] = 1e18;
ll lo = 1, hi = k;
while (lo <= hi){
ll mid = (lo + hi) >> 1;
ll cost = 1e18;
cost = min(cost, 1ll * position[i - 1] * 2);
cost = min(cost, (1ll * l - position[max(i - mid, 0ll)]) * 2);
cost = min(cost, 1ll * l);
if (cost < l) lo = mid + 1;
else hi = mid - 1;
}
ll cost = 1e18;
cost = min(cost, 1ll * position[i - 1] * 2);
cost = min(cost, (1ll * l - position[max(i - hi, 0ll)]) * 2);
cost = min(cost, 1ll * l);
dp[i] = min(dp[i], dp[max(0ll, i - hi)] + cost);
cost = 1e18;
cost = min(cost, 1ll * position[i - 1] * 2);
cost = min(cost, (1ll * l - position[max(i - k, 0)]) * 2);
cost = min(cost, 1ll * l);
dp[i] = min(dp[i], dp[max(0, i - k)] + cost);
}
return dp[n];
}
/*
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("VietCT.INP", "r")){
freopen("VietCT.INP", "r", stdin);
freopen("VietCT.OUT", "w", stdout);
}
}
/*
*/
Compilation message (stderr)
boxes.cpp:45:1: warning: "/*" within comment [-Wcomment]
45 | /*
|
# | 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... |