Submission #930435

#TimeUsernameProblemLanguageResultExecution timeMemory
930435CutebolBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
479 ms294212 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std ; const int N = 1e7 + 4 ; template <class T> bool chmin( T &x , const T &y ){ bool f = 0 ; if ( x > y ) x = y , f = 1 ; return f ; } long long dpl[N] , dpr[N] ; long long delivery(int n, int k, int l, int a[]) { for ( int i = 1 ; i <= n ; i ++ ) dpl[i] = dpl[max(i-k,0)] + min(l,2*a[i-1]) ; for ( int i = n ; i > 0 ; i -- ) dpr[i] = dpr[min(i+k,n+1)] + min(l,2*(l-a[i-1])) ; long long ans = min(dpr[1],dpl[n]) ; for ( int i = 1 ; i < n ; i ++ ) chmin ( ans , dpl[i]+dpr[i+1] ) ; return ans ; } /* int a[N] ; signed main(){ int n , k , l ; cin >> n >> k >> l ; for ( int i = 0 ; i < n ; i ++ ) cin >> a[i] ; cout << delivery( n , k , l , a ) ; } //*/
#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...