제출 #1195643

#제출 시각아이디문제언어결과실행 시간메모리
1195643dosts선물상자 (IOI15_boxes)C++20
20 / 100
0 ms328 KiB
#include "boxes.h" #include <bits/stdc++.h> #pragma GCC target("lzcnt,popcnt") #pragma GCC optimize("O3,unroll-loops") #define int long long #define pii pair<int,int> #define vi vector<int> #define ff first #define ss second #define all(x) x.begin(),x.end() #define sp << " " << using namespace std; int delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) { vi sol,sag; for (int i = 0;i<N;i++) { if (p[i] <= L/2) sag.push_back(p[i]); else break; } for (int i = N-1;i>=0;i--) { if (p[i] > L/2) sol.push_back(p[i]); else break; } int ans = 0; while (sag.size() >= K) { ans+=2*sag.back(); for (int j = 0;j<K;j++) sag.pop_back(); } while (sol.size() >= K) { ans+=2*(L-sol.back()); for (int j = 0;j<K;j++) sol.pop_back(); } int op1 = ((sol.empty())?0ll:(2*(L-sol.back())))+((sag.empty())?0ll:(2*sag.back())); vi lst; for (auto it : sag) lst.push_back(it); for (int i = sol.size()-1;i>=0;i--) lst.push_back(sol[i]); int op2 = 2e18; if (lst.size() <= K) op2 = L; else { op2 = L+2*min(L-lst[K],lst[lst.size()-K-1]); } return ans+min(op1,op2); }
#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...