Submission #813312

#TimeUsernameProblemLanguageResultExecution timeMemory
813312OrazBBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
2073 ms6812 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], dp[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[]){ dp[0] = min(F(p[0], 1, L), F(p[0], 0, L)); for (int i = 1; i < n; i++){ dp[i] = 1e18; for (int j = i; j >= 0; j--){ if (i-j+1 > K) break; dp[i] = min(dp[i], (j ? dp[j-1] : 0)+min(F(p[i], 0, L), F(p[j], 1, L))); } assert(dp[i] >= dp[i-1]); } return dp[n-1]; } // 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...