이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
const ll inf = 1e18 + 10000;
const int mod = 1e9+7;
const int maxn = 1e5 + 12;
long long delivery(int n, int k, int l, int p[]) {
ll ret = inf;
ll s[n + 1], pr[n + 1];
s[n] = pr[n] = 0;
for(int i = n - 1; i >= 0; i--){
int x = p[i], y = p[min(i + k - 1, n - 1)];
s[i] = min({y * 2, (l - x) * 2, l});
s[i] += s[min(n, i + k)];
}
ret = s[0];
for(int i = 0; i < n; i++){
int x = p[max(0, i - k + 1)], y = p[i];
pr[i] = min({y * 2, (l - x) * 2, l});
if(i >= k)pr[i] += pr[i - k];
ret = min(ret, pr[i] + s[i + 1]);
}
return ret;
}
//int main(){
//int n, k, l;
//cin >> n >> k >> l;
//int p[n];
//for(int i = 0; i < n; i++){
//cin >> p[i];
//}
//cout << delivery(n, k, l, p);
//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... |