제출 #620998

#제출 시각아이디문제언어결과실행 시간메모리
620998jeroenodb선물상자 (IOI15_boxes)C++14
100 / 100
632 ms230076 KiB
#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int oo = 1e9; #include "boxes.h" vector<ll> getCost(int n, int k, int p[]) { vector<ll> pref(n+1); vector<ll> p2(k); for(int i=0;i<n;++i) { p2[i%k]+=2*(p[i]-(i?p[i-1]:0)); pref[i+1]=pref[i]+p2[i%k]; } return pref; } long long delivery(int N, int K, int L, int p[]) { auto c1 = getCost(N,K,p); reverse(p,p+N); for(int i=0;i<N;++i) p[i] = L-p[i]; auto c2 = getCost(N,K,p); reverse(all(c2)); ll ans = 1e18; for(int i=0;i<=N;++i) { ans = min(ans,c1[i]+c2[i]); } for(int i=0;i+K<=N;++i) { ans = min(ans,L+c1[i]+c2[i+K]); } 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...