제출 #1203393

#제출 시각아이디문제언어결과실행 시간메모리
1203393AMel0n선물상자 (IOI15_boxes)C++20
25 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() // #define F first // #define S second #include "boxes.h" ll delivery(int N, int K, int L, int p[]) { // never optimal to take more than one full circle vector<ll> dp(N+1); ll mxL= 0, mxR = 0; ll i = 0; while((ll)p[i] <= L/2 && i < N) { if (i-K >= 0) dp[i] = dp[i-K] + 2ll*(ll)p[i]; else dp[i] = 2ll*(ll)p[i]; mxL = max(mxL, dp[i]); i++; } i = N-1; while((ll)p[i] > L/2 && i >= 0) { if (i+K < N) dp[i] = dp[i+K] + 2ll*((ll)L-(ll)p[i]); else dp[i] = 2ll*((ll)L-(ll)p[i]); mxR = max(mxR, dp[i]); i--; } ll res = mxL + mxR; FOR(i, N) { if (i+K+1 <= N && p[i] <= L/2 && p[i+K] > L/2) res = min(res, L + dp[i] + dp[i+K+1]); } return res; }
#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...