제출 #127956

#제출 시각아이디문제언어결과실행 시간메모리
127956SOIVIEONE선물상자 (IOI15_boxes)C++14
100 / 100
588 ms215032 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long dp[N+2], pd[N + 2]; long long n = N, k = K, l = L; dp[0] = 0; for(int i = 1; i <= n; i ++) dp[i] = dp[max(0ll, i - k)] + p[i - 1] * 2ll; pd[n + 1] = 0; for(int i = n; i >= 1; i --) pd[i] = pd[min(n + 1, i + k)] + (L-p[i - 1]) * 2ll; long long ans = 1e18; for(int i = 1; i <= n+1; i ++) ans = min(ans, dp[i - 1] + pd[i]); for(int i = 0; i < n; i ++) { if(i + k <= n) ans = min(ans, l + dp[i] + pd[i + k + 1]); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  for(int i = n; i >= 1; i --)
              ^
#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...