Submission #364072

#TimeUsernameProblemLanguageResultExecution timeMemory
364072knightron0Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
626 ms274540 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second #define clr(a, x) memset(a, x, sizeof(a)) #define dbg(x) cout<<"("<<#x<<"): "<<x<<endl; #define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define all(v) v.begin(), v.end() #define lcm(a, b) (a * b)/__gcd(a, b) #define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl; #define endl '\n' #define lli long long int #define float long double const int MOD = 1e9 + 7; const int MAXN = 1e5 + 5; lli delivery(int n, int k, int l, int positions[]) { int tm_left[n+2], tm_right[n+2]; for(int i= 1;i<=n;i++){ int x= positions[i-1]; tm_left[i] = min(x*2, l); int y = l-x; tm_right[i] = min(y*2, l); } lli dp[n+3][2]; clr(dp, 0); for(int i= 1;i<=n;i++){ if(i > k){ dp[i][0] = dp[i-k][0] + tm_left[i]; } else { dp[i][0] = tm_left[i]; } } lli ans= LLONG_MAX; for(int i= n;i>=1;i--){ if(i+k <= n){ dp[i][1] = dp[i+k][1] + tm_right[i]; } else { dp[i][1] = tm_right[i]; } ans = min(ans, (lli)dp[i][1]+dp[i-1][0]); } ans = min(ans, (lli)dp[n][0]); return ans; } // signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // #ifdef LOCAL // freopen("input.txt", "r", stdin); // #endif // int n, k, l; // cin>>n>>k>>l; // int pos[n]; // for(int i= 0;i<n;i++){ // cin>>pos[i]; // } // cout<<delivery(n, k, l, pos)<<endl; // return 0; // }
#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...