제출 #471992

#제출 시각아이디문제언어결과실행 시간메모리
471992nicholask선물상자 (IOI15_boxes)C++14
0 / 100
1 ms204 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]){ vector <int> v; v.push_back(0); for (int i=0; i<N; i++){ if (p[i]) v.push_back(p[i]); } int n=v.size(); long long dp0[n+1],dp1[n+1]; dp0[0]=dp1[n]=0; for (int i=1; i<n; i++){ if (i<=K) dp0[i]=min(1ll*L,2ll*v[i]); else dp0[i]=dp0[i-K]+min(1ll*L,2ll*v[i]); } for (int i=n-1; i>0; i--){ if (n-i<=K) dp1[i]=min(1ll*L,2ll*L-v[i]); else dp1[i]=dp1[i+K]+min(1ll*L,2ll*(L-v[i])); } long long ans=1e18; for (int i=0; i<n; i++) ans=min(ans,dp0[i]+dp1[i+1]); for (int i=0; i+K<n; i++) ans=min(ans,dp0[i]+dp1[i+K+1]+L); return ans; } /* signed main(){ int n,k,l; cin>>n>>k>>l; int p[n]; for (int i=0; i<n; i++) cin>>p[i]; cout<<delivery(n,k,l,p)<<'\n'; } */

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

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