Submission #1009753

#TimeUsernameProblemLanguageResultExecution timeMemory
1009753hotboy2703Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
445 ms293872 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; using ll = long long; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) const ll MAXN = 1e7 + 100; ll dp1[MAXN]; ll dp2[MAXN]; long long delivery(int n, int k, int L, int p[]) { ll res = 1e18; for (ll i = 0;i < n;i ++){ ll id_l = (i-k+1); if (id_l < 0)id_l = 0; if (p[id_l] * 2 > L){ dp1[i] = -1; continue; } if (i-k>=0){ dp1[i] = dp1[i-k] + min(L,p[i]*2); } else{ dp1[i] = min(L,p[i]*2); } if (i == n - 1)res = min(res,dp1[i]); } for (ll i = n - 1;i >= 0;i --){ if (p[i] * 2 <= L)break; if (i + k >= n){ dp2[i] = min(L,(L-p[i])*2); } else{ dp2[i] = min(L,(L-p[i])*2)+dp2[i+k]; } ll id_l = i-k; if (id_l < 0)id_l = 0; if (i >= 1 && p[id_l] * 2 <= L){ res = min(res,dp2[i]+dp1[i-1]); } if (i==0)res = min(res,dp2[i]); } // for (ll i = 0;i < n;i ++){ // cout<<dp1[i]<<' '; // } // cout<<'\n'; // for (ll i = 0;i < n;i ++){ // cout<<dp2[i]<<' '; // } // cout<<'\n'; 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...