제출 #801801

#제출 시각아이디문제언어결과실행 시간메모리
801801_martynas선물상자 (IOI15_boxes)C++11
100 / 100
588 ms202776 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; i < N; i++) { cost[i] += p[i]; if(i-K >= 0) cost[i] += cost[i-K]+p[i-K]; } return cost; } long long delivery(int N, int K, int L, int p[]) { int zeroes = count(p, p+N, 0); N -= zeroes; for(int i = 0; i < N; i++) p[i] = p[i+zeroes]; 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 = 0; i < N; i++) { p[i] = (p[i] != 0 ? L-p[i] : p[i]); } 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[]) {
      |                                                 ~~~~^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:16:23: warning: conversion from 'std::iterator_traits<int*>::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   16 |     int zeroes = count(p, p+N, 0);
      |                  ~~~~~^~~~~~~~~~~
#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...