제출 #1084897

#제출 시각아이디문제언어결과실행 시간메모리
1084897the_coding_pooh선물상자 (IOI15_boxes)C++14
0 / 100
1 ms604 KiB
#include "boxes.h" #include <bits/stdc++.h> #define uwu return ans; using namespace std; const int SIZE = 1e7 + 5; const long long INF = 1e18; long long dp[SIZE]; #define fs first #define sc second long long delivery(int N, int K, int L, int p[]) { long long ans = INF; vector <long long> pos; pos.push_back(0); for(int i = 0; i < N; i++){ pos.push_back(p[i]); } deque <pair<long long, long long>> with_p, no_p; with_p.push_back({L, 0}); no_p.push_back({0, 0}); for(int i = 1; i <= N; i++){ while(with_p.front().sc < i - K){ with_p.pop_front(); } while(no_p.front().sc < i - K){ no_p.pop_front(); } dp[i] = min(with_p.front().fs, no_p.front().fs + 2 * pos[i]); long long now_p = min((long long)L, 2 * (L - pos[i])); while(!with_p.empty() && with_p.back().fs > dp[i] + now_p){ with_p.pop_back(); } with_p.push_back({dp[i] + now_p, i}); while(!no_p.empty() && no_p.back().fs > dp[i]){ no_p.pop_back(); } no_p.push_back({dp[i], i}); } ans = dp[N]; uwu }
#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...