제출 #65331

#제출 시각아이디문제언어결과실행 시간메모리
65331daniel_02선물상자 (IOI15_boxes)C++17
10 / 100
3 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; long long delivery(int N, int K, int L, int p[]) { long long ans; ans = 1LL * 1e18 + 7; for (int i = 0; i < N; i++) { ll cur = 0; if (p[i] > L / 2) break; for (int j = i; j >= 0; j -= K) { if (p[j] <= L / 2) cur += (p[j] * 2); else { if (j - K + 1 >= 0) { cur += min((L - p[j - K + 1]) * 2, L); } else { if (p[0] > L / 2) cur += min((L - p[0]) * 2, L); else cur += L; } } } for (int j = i + 1; j < N; j += K) { if (p[j] > L / 2) { cur += ((L - p[j]) * 2); } else { if (j + K - 1 < N) { cur += min(p[j + K - 1] * 2, L); } else { if (p[N - 1] <= L / 2) cur += min(p[N - 1] * 2, L); else cur += L; } } } ans = min(ans, cur); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...