이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//In the name of God
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 1e7 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll dp1[maxn], dp2[maxn], mn[maxn];
long long delivery(int n, int k, int L, int p[]) {
for(ll i = 0; i < k; i++){
dp1[i] = p[i] * 2;
dp2[n - 1 - i] = (L - p[n - 1 - i]) * 2;
}
for(ll i = k; i < n; i++){
dp1[i] = dp1[i - k] + p[i] * 2;
dp2[n - 1 - i] = dp2[n - 1 - i + k] + (L - p[n - 1 - i]) * 2;
}
fill(mn, mn + k, inf);
ll ans = min(dp1[n - 1], dp2[0]);
for(ll i = 0; i < n; i++){
ans = min(ans, L * ((i - 1) / k) + mn[(i - 1 + k) % k] + dp2[i]);
mn[i % k] = min(mn[i % k], dp1[i] - L * (i / k));
}
return ans;
}
/*int main(){
fast_io;
return 0;
}*/
# | 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... |