제출 #519614

#제출 시각아이디문제언어결과실행 시간메모리
519614silverfish선물상자 (IOI15_boxes)C++17
70 / 100
2059 ms213600 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; const int N = 10000007; ll dp[N], s[N]; set<array<ll,2>> st; inline ll mn(ll a, ll b){ return (a < b ? a : b); } long long delivery(int n, int k, int L, int p[]) { ll l = L; fill(dp, dp+N, 1e18+10); // sort(p, p+n); for(int i = 0; i < n; ++i){ s[i] = (i ? dp[i-1] : 0) + mn(2LL*(l-p[i]), l); st.insert({s[i], i}); if(i-k >= 0) st.erase(st.find({s[i-k], i-k})); auto it = st.begin(); int pos = (*it)[1]; dp[i] = dp[pos-1]+mn(l, mn(2LL*p[i], 2LL*(l-p[pos]))); } return dp[n-1]; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:25:20: warning: conversion from 'std::array<long long int, 2>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   25 |   int pos = (*it)[1];
      |                    ^
#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...