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>
#define uwu return ans;
using namespace std;
const int SIZE = 1e7 + 5;
const long long INF = 1e18;
long long dp[SIZE];
#define fs first
#define sc second
long long delivery(int N, int K, int L, int p[]) {
long long ans = INF;
vector <long long> pos;
pos.push_back(0);
for(int i = 0; i < N; i++){
pos.push_back(p[i]);
}
pos.push_back(0);
deque <pair<long long, long long>> with_p, no_p;
with_p.push_back({min((long long)L, 2 * (L - pos[1])), 0});
no_p.push_back({0, 0});
for(int i = 1; i <= N; i++){
while(with_p.front().sc < i - K){
with_p.pop_front();
}
while(no_p.front().sc < i - K){
no_p.pop_front();
}
dp[i] = min(with_p.front().fs, no_p.front().fs + 2 * pos[i]);
long long now_p = min((long long)L, 2 * (L - pos[i + 1]));
while(!with_p.empty() && with_p.back().fs > dp[i] + now_p){
with_p.pop_back();
}
with_p.push_back({dp[i] + now_p, i});
while(!no_p.empty() && no_p.back().fs > dp[i]){
no_p.pop_back();
}
no_p.push_back({dp[i], i});
}
ans = dp[N];
uwu
}
# | 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... |