제출 #725821

#제출 시각아이디문제언어결과실행 시간메모리
725821TheSahib선물상자 (IOI15_boxes)C++17
20 / 100
1 ms308 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; const ll oo = 1e18; ll delivery(int N, int K, int M, int p[]) { vector<int> v; for (int i = 0; i < N; i++) { if(p[i] == 0) continue; v.push_back(p[i]); } N = v.size(); K = min(K, int(v.size())); if(N == 0) return 0; ll L[N + 1], R[N + 1]; L[0] = 0; for (int i = 1; i <= N; i++) { L[i] = L[(i - 1) / K * K] + v[i - 1] * 2; } R[0] = 0; for (int i = 1; i <= N; i++) { R[i] = R[(i - 1) / K * K] + (M - v[N - i]) * 2; } ll ans = oo; for (int i = 0; i <= N; i++) { ans = min(ans, L[i] + R[N - i]); if(N - i - K >= 0){ ans = min(ans, L[i] + R[N - i - K] + M); } } return ans; }

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

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