제출 #604272

#제출 시각아이디문제언어결과실행 시간메모리
604272cheissmart선물상자 (IOI15_boxes)C++14
50 / 100
2064 ms24968 KiB
#include "boxes.h" #include <bits/stdc++.h> #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7; const ll oo = 1e18; ll delivery(int n, int k, int l, int p[]) { vi a; for(int i = 0; i < n; i++) if(p[i]) a.PB(p[i]); n = SZ(a); vi x, y; for(int i = 0; i < n; i++) { if(a[i] < l - a[i]) { x.PB(a[i]); } else if(l - a[i] < a[i]) { y.PB(l - a[i]); } } reverse(ALL(y)); assert(is_sorted(ALL(x))), assert(is_sorted(ALL(y))); auto go = [&] (vi tt) { V<ll> dp(SZ(tt) + 1); for(int i = 0; i < SZ(tt); i++) { dp[i + 1] = dp[max(0, i + 1 - k)] + tt[i] * 2; } return dp; }; V<ll> dx = go(x), dy = go(y); ll ans = oo; for(int i = 0; i < SZ(dx); i++) for(int j = 0; j < SZ(dy); j++) ans = min(ans, dx[i] + dy[j] + 1LL * (n - i - j + k - 1) / k * l); cerr << ans << endl; 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...