제출 #580356

#제출 시각아이디문제언어결과실행 시간메모리
580356alirezasamimi100선물상자 (IOI15_boxes)C++17
70 / 100
2101 ms327392 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; using ll = long long int; using pll = pair<ll, ll>; ll delivery(int N, int K, int L, int p[]) { ll dp[N + 2], pd[N + 2], ans = 1e18; vector<ll> vec = {-1}; priority_queue<pll, vector<pll>, greater<pll>> st; for(int i = 0; i < N; i++) if(p[i]) vec.pb(p[i]); dp[0] = pd[vec.size()] = 0; st.push({0, 0}); for(int i = 1; i < (int)vec.size(); i++){ while(st.top().S < i - K) st.pop(); dp[i] = st.top().F + vec[i] + min(vec[i], L - vec[i]); st.push({dp[i], i}); } while(!st.empty()) st.pop(); st.push({0, vec.size()}); for(int i = (int)vec.size() - 1; i; i--){ while(st.top().S > i + K) st.pop(); pd[i] = st.top().F + L - vec[i] + min(vec[i], L - vec[i]); st.push({pd[i], i}); } for(ll i = 0; i < (int)vec.size(); i++) ans = min(ans, dp[i] + pd[i + 1]); return ans; }
#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...