Submission #532035

#TimeUsernameProblemLanguageResultExecution timeMemory
532035nguyentunglamBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
538 ms249300 KiB
#include<bits/stdc++.h> #define forin(i, a, b) for(int i = a; i <= b; i++) #define forde(i, a, b) for(int i = a; i >= b; i--) #define fi first #define se second #define ll long long using namespace std; const int N = 1e7 + 10; ll dp[2][N]; ll delivery(int n, int k, int l,int a[]) { ll res = 1e18; //forin(i, 1, n) cin >> a[i]; forin(i, 1, n) dp[0][i] = dp[0][max(0, i-k)] + a[i-1] + min(a[i-1], l-a[i-1]); forde(i, n, 1) dp[1][i] = dp[1][min(n+1, i+k)] + l-a[i-1] + min(a[i-1], l - a[i-1]); forin(i, 1, n+1) res = min(res, dp[0][i-1] + dp[1][i]); //forde(i, n, 1) cout << dp[1][i]<<" "; 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...