제출 #1086549

#제출 시각아이디문제언어결과실행 시간메모리
1086549Pacybwoah선물상자 (IOI15_boxes)C++17
50 / 100
2033 ms25792 KiB
#include "boxes.h" #include<iostream> #include<vector> #include<algorithm> using namespace std; typedef long long ll; long long delivery(int N, int K, int L, int p[]) { vector<int> vec; for(int i = 0; i < N; i++) if(p[i] > 0) vec.push_back(p[i]); int n = vec.size(); if(n == 0) return 0; int k = K; auto calc = [&](int l, int r){ if(l > r) return 0; return min(min(vec[r] * 2, (L - vec[l]) * 2), L); }; vector<ll> dp(n + 1, 1e18); dp[0] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j < i; j++){ if(i - j <= k) dp[i] = min(dp[i], dp[j] + calc(j, i - 1)); } } return dp[n]; } // g++ -std=c++17 -o run -Wshadow -Wall -Wextra -fsanitize=undefined -fsanitize=address boxes.cpp grader.cpp

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:11:21: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   11 |     int n = vec.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...