제출 #923189

#제출 시각아이디문제언어결과실행 시간메모리
923189Macker선물상자 (IOI15_boxes)C++14
10 / 100
1 ms348 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(v) v.begin(), v.end() long long delivery(int N, int K, int L, int p[]) { ll n = N; ll k = K; ll l = L; vector<ll> v(p, p + N); ll dist = 0; ll s = 0, e = n; for (ll i = k - 1; i < n && v[i] <= l / 2; i += k) { dist += 2 * v[i]; s = i + 1; } for (ll i = n - k; i >= 0 && v[i] > l / 2; i -= k) { dist += 2 * (l - v[i]); e = i; } ll a = 0; for (ll i = s; i < n && v[i] <= l / 2; i++) { a = 2 * v[i]; } ll b = 0; for (ll i = e - 1; i >= 0 && v[i] > l / 2; i--) { b = 2 * (l - v[i]); } ll mxs, mxe, mx = -1; for (ll i = 0; i < n - k; i++) { if(i <= s && i + k >= e){ if(p[i + k - 1] - p[i] > mx){ mx = p[i + k - 1] - p[i]; mxs = i; mxe = i + k - 1; } } } if(mx == -1) return dist + a + b; ll sub = l + (p[mxs] - p[s]) + (p[e] - p[mxe]); return min(dist + a + b, dist + sub); }
#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...