Submission #1122617

#TimeUsernameProblemLanguageResultExecution timeMemory
1122617heeyBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
0 ms324 KiB
#include<bits/stdc++.h> #define f first #define s second #define all(x) (x).begin(), (x).end() #define mod 1'000'000'007 #define inf 1'000'000'000'000'00 #define pb push_back #define vvi vector<vi> #define fst ios_base::sync_with_stdio(0);cin.tie(0); #include "boxes.h" using namespace std; long long delivery(int n, int K, int L, int a[]){ int res = 0; vector<int> dp(n); dp[0] = 2*min(a[0], L - a[0]); for(int i = 1; i < n-1; i++){ dp[i] = dp[i-1]; if(i % K == 0) dp[i] += 2*min(a[i], L - a[i]); else dp[i] = dp[i-1] + 2*min(a[i] - a[i-1], a[i+1] - a[i]); } if(n > 1){ dp[n-1] = dp[n-2]; if(n-1 % K == 0) dp[n-1] += 2*min(a[n-1], L - a[n-1]); else dp[n-1] += 2*min(a[n-1] - a[n-2], L - a[n-1]); } return dp[n-1]; }
#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...