Submission #1203391

#TimeUsernameProblemLanguageResultExecution timeMemory
1203391AMel0nBoxes with souvenirs (IOI15_boxes)C++20
0 / 100
0 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; FOR(i, N) { if ((ll)p[i] <= (ll)L/2) { 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]); } else { if (i+K <= N) dp[i] = dp[(i+K)%N] + 2ll*((ll)L-(ll)p[i]); else dp[i] = 2ll*((ll)L-(ll)p[i]); mxR = max(mxR, dp[i]); } } ll res = mxL + mxR; FOR(i, N) { if (i+K+1 <= N && (ll)p[i] <= (ll)L/2 && (ll)p[i+K] > (ll)L/2) res = min(res, (ll)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...