제출 #801541

#제출 시각아이디문제언어결과실행 시간메모리
801541_martynas선물상자 (IOI15_boxes)C++11
10 / 100
1 ms300 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; vector<long long> get_cost_vector(int N, int K, int L, int p[]) { vector<long long> cost(N); for(int i = 0, cnt = K; i < N; i++, cnt--) { if(cnt == 0) { cnt = K, cost[i] += 2*p[i-1]; } cost[i] += p[i]-(i?p[i-1]:0); if(i) cost[i] += cost[i-1]; } return cost; } long long delivery(int N, int K, int L, int p[]) { vector<long long> cost_l = get_cost_vector(N, K, L, p); reverse(p, p+N); for(int i = 0; i < N; i++) { p[i] = (p[i] != 0 ? L-p[i] : p[i]); } vector<long long> cost_r = get_cost_vector(N, K, L, p); long long ans = min(cost_l[N-1]+p[0], cost_r[N-1]+p[N-1]); ans = min(ans, min(cost_l[N-1]+(L-p[0]), cost_r[N-1]+(L-p[N-1]))); reverse(cost_r.begin(), cost_r.end()); reverse(p, p+N); for(int i = 1; i < N; i++) { ans = min(ans, cost_l[i-1]+min(p[i-1], L-p[i-1])+cost_r[i]+min(p[i], L-p[i])); } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'std::vector<long long int> get_cost_vector(int, int, int, int*)':
boxes.cpp:6:53: warning: unused parameter 'L' [-Wunused-parameter]
    6 | vector<long long> get_cost_vector(int N, int K, int L, int p[]) {
      |                                                 ~~~~^
#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...