Submission #28758

#TimeUsernameProblemLanguageResultExecution timeMemory
28758noobprogrammerBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
2 ms380 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std ; #define ii pair<int,int> #define fi first #define se second #define vi vector<int> #define vii vector<ii> typedef long long ll ; ll pre[10000010] , suf[10000010] ; long long delivery(int n, int k, int L , int arr[]) { ll l = L ; for(int i=0;i<n;i++){ if(i < k) pre[i] = 2LL*arr[i] ; else pre[i] = 2LL*arr[i] + pre[i-k] ; } for(int i=n-1; i >= 0 ;i--){ if(n - i - 1 < k) suf[i] = 2LL*(l - arr[i]) ; else suf[i] = suf[i+k] + 2LL* (l-arr[i]) ; } ll res = l + suf[k] ; for(int i = k ; i<n ; i++) res = min(res , pre[i-k] + l + suf[k+1]) ; res = min(res , suf[0]) ; for(int i=0;i<n;i++) res = min(res , pre[i] + suf[i+1]) ; 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...