제출 #813274

#제출 시각아이디문제언어결과실행 시간메모리
813274OrazB선물상자 (IOI15_boxes)C++14
20 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <int, int> #define pb push_back #define ff first #define ss second const int N = 1e7+5; ll suff[N], pref[N]; ll F(ll x, int t, ll L){ ll cur = (t ? (L-x)*2 : x*2); return min(L, cur); } ll delivery(int n, int K, int L, int p[]){ for (int i = 0; i < n; i++){ if (i) pref[i] = pref[i-1]; if ((i+1)%K == 0) pref[i] += F(p[i], 0, L); } for (int i = n-1; i >= 0; i--){ suff[i] = suff[i+1]; if ((n-i)%K == 0) suff[i] += F(p[i], 1, L); } ll a = suff[0], b = pref[n-1]; if (n%K){ a += F(p[0], 1, L); b += F(p[n-1], 0, L); } ll mn = min(a, b); for (int i = 0; i < n-1; i++){ ll x = pref[i]; if ((i+1)%K) x += F(p[i], 0, L); x += suff[i+1]; if ((n-i-1)%K) x += F(p[i+1], 1, L); mn = min(mn, x); } return mn; } // int main () // { // ios::sync_with_stdio(false); // cin.tie(0); // int n, k, l; // cin >> n >> k >> l; // int p[n]; // for (int i = 0; i < n; i++) cin >> p[i]; // cout << delivery(n, k, l, p); // }
#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...