Submission #592096

#TimeUsernameProblemLanguageResultExecution timeMemory
592096talant117408Boxes with souvenirs (IOI15_boxes)C++17
50 / 100
2037 ms37300 KiB
#include "boxes.h" #include <bits/stdc++.h> #ifndef EVAL #include "grader.cpp" #endif using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define pb push_back #define mp make_pair #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define lb lower_bound #define ub upper_bound #define sz(v) int((v).size()) #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl '\n' long long delivery(int n, int k, int L, int P[]) { ll l, p[n]; l = L; for (int i = 0; i < n; i++) { p[i] = P[i]; } sort(p, p + n); ll pref[n], suff[n]; for (int i = 0; i < n; i++) { pref[i] = p[i] * 2; if (i >= k) { pref[i] += pref[i - k]; } } for (int i = n - 1; i >= 0; i--) { suff[i] = (l - p[i]) * 2; if (i + k < n) { suff[i] += suff[i + k]; } } ll ans = 1e18; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { if (i + j > n) break; ans = min(ans, (n - i - j - 1 + k) / k * l + (i ? pref[i - 1] : 0) + (j ? suff[n - j] : 0)); } } 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...