이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e7 + 5;
int n, k, l;
int a[maxn];
vector<int> solve() {
int cnt[k];
for (int i=0;i<k;i++) cnt[i] = 0;
vector<int> cost(n);
for (int i=0;i<n;i++) {
cnt[i%k] += a[i] * 2;
cost[i] = cnt[i%k];
}
return cost;
}
long long delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) {
k = K, l = L;
n = 0;
for (int i=0;i<N;i++) {
if (p[i]!=0) a[n] = p[i], n++;
}
if (n==0) return (int)0;
sort(a, a+n);
int ans = min({a[n-1]*2, (L-a[0])*2, n});
for (int i=0;i<n-1;i++) ans = min(a[i]*2 + (L-a[i+1])*2, ans);
return ans;
// vector<int> fwd = solve();
// for (int i=0;i<n;i++) a[i] = L - a[i];
// reverse(a, a+n);
// // for (int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
// vector<int> bwd = solve();
// reverse(bwd.begin(), bwd.end());
// // for (int i=0;i<n;i++) cout << fwd[i] << " "; cout << endl;
// // for (int i=0;i<n;i++) cout << bwd[i] << " "; cout << endl;
// int ans = min(fwd[n-1], bwd[0]);
// for (int i=0;i<n-1;i++) ans = min(fwd[i] + bwd[i+1], ans);
// // cout << ans << endl;
// return ans;
}
# | 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... |