Submission #685115

#TimeUsernameProblemLanguageResultExecution timeMemory
685115viciousBoxes with souvenirs (IOI15_boxes)C++17
25 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define si second typedef pair<int,int> pi; typedef tuple<int,int,int> ti; template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;} template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;} void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) const int MAXN=1e7+10; int n,k,l,a[MAXN]; ll dp[2][MAXN],ans=1e18; long long delivery(int N, int K, int L, int p[]) { n=N,k=K,l=L; for (int i = 0; i < n; ++i) a[i+1]=p[i]; for (int i = 1; i <= n; ++i) { if (i<k) dp[0][i]=2*a[i]; else dp[0][i]=dp[0][i-k]+2*a[i]; } for (int i = n; i >= 1; --i) { if (i>n-k) dp[1][i]=2*(l-a[i]); else dp[1][i]=dp[1][i+k]+2*(l-a[i]); } ans = min(dp[0][n],dp[1][1]); for (int i = 1; i < n; ++i) { chmin(ans, dp[0][i]+dp[1][i+1]); } for (int i = 1; i <= n-k; ++i) { chmin(ans, dp[0][i]+dp[1][i+k+1]+l); } return ans; }
#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...