제출 #479867

#제출 시각아이디문제언어결과실행 시간메모리
479867ntabc05101선물상자 (IOI15_boxes)C++14
100 / 100
664 ms333120 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; #define taskname "CAKES" const int mxN = 1000000; long long delivery(int n, int k, int l, int P[]) { vector<int> p; for (int i = 0; i < n; i++) { auto &x = P[i]; if (x != 0) { p.push_back(x); } } n = p.size(); //return 0; vector<long long> dp_cw(n), dp_ccw(n); for (int i = 0; i < n; i++) { if (i < k) { dp_cw[i] = min(l, 2 * p[i]); } else { dp_cw[i] = min(l, 2 * p[i]) + dp_cw[i - k]; } } for (int i = n - 1; i >= 0; i--) { if (i >= n - k) { dp_ccw[i] = min(l, 2 * (l - p[i])); } else { dp_ccw[i] = min(l, 2 * (l - p[i])) + dp_ccw[i + k]; } } long long res = min(dp_cw[n - 1], dp_ccw[0]); for (int i = 1; i < n; i++) { res = min(res, dp_cw[i - 1] + dp_ccw[i]); } return res; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:13: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   17 |   n = p.size();
      |       ~~~~~~^~
#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...