# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
780201 | vjudge1 | 선물상자 (IOI15_boxes) | C++17 | 51 ms | 4444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<long long, long long>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define ll long long
long long delivery(int N, int K, int L, int p[]) {
int n = N, k = K, l = L;
sort(p, p + n);
ll curr = 0;
for (int i = 0; i < n; i += k){
int to = min(n - 1, i + k - 1);
if (p[to] <= L / 2){
curr += 2 * p[to];
}
else if (p[i] >= L / 2){
curr += 2 * (L - p[i]);
}
else curr += L;
}
ll ans = curr;
curr = 0;
int pos = 0;
while(pos < n && p[pos] <= L / 2) pos++;
for (int i = pos - 1; i >= 0; i -= k){
int to = max(0, i - k + 1);
curr += 2 * min(p[i], L / 2);
}
for (int i = pos; i < n; i += k){
int to = min(n - 1, i + k - 1);
curr += 2 * (L - p[i]);
}
ans = min(ans, curr);
curr = 0;
pos = 0;
while(pos < n && p[pos] < L / 2) pos++;
for (int i = pos - 1; i >= 0; i -= k){
int to = max(0, i - k + 1);
curr += 2 * min(p[i], L / 2);
}
for (int i = pos; i < n; i += k){
int to = min(n - 1, i + k - 1);
curr += 2 * (L - p[i]);
}
ans = min(ans, curr);
curr = 0;
reverse(p, p + n);
for (int i = 0; i < n; i += k){
int to = min(n - 1, i + k - 1);
if (p[i] <= L / 2){
curr += 2 * p[i];
}
else if (p[to] >= L / 2){
curr += 2 * (L - p[to]);
}
else curr += L;
}
return min(ans, curr);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |