이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In the name of Allah
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e7 + 4;
const ll oo = 1e18 + 4;
ll dp[maxn], val[maxn]; deque<int> dq;
ll delivery(int N, int K, int L, int p[]) {
for (int i = 0; i <= N; i++) {
while (!dq.empty() && dq.front() < i - K) dq.pop_front();
if (i == 0) dp[i] = 0;
else dp[i] = val[dq.front()] + min(p[i - 1], L - p[i - 1]) - (L - p[i - 1]);
if (i < N) val[i] = dp[i] + min(p[i], L - p[i]) + (L - p[i]);
else val[i] = oo;
while (!dq.empty() && val[dq.back()] >= val[i]) dq.pop_back();
dq.pb(i);
}
return dp[N];
}
# | 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... |