제출 #1162191

#제출 시각아이디문제언어결과실행 시간메모리
1162191gustavo_dBoxes with souvenirs (IOI15_boxes)C++20
50 / 100
2095 ms19780 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll INF = 1e18;

ll delivery(int n, int k, int len, int p[]) {
    ll ans = INF;
    ll dpL[n]; dpL[0] = 0;
    for (int i=0; i<=n; i++) {
        if (i != 0 and i <= k) dpL[i] = 2*p[i-1];
        else if (i != 0) dpL[i] = 2*p[i-1] + dpL[i-k];

        ll dpR[n]; dpR[0] = 0;
        for (int j=0; j<=n-i; j++) {
            if (j != 0 and j <= k) dpR[j] = 2*(len - p[n-j]);
            else if (j != 0) dpR[j] = 2LL*(len-p[n-j]) + dpR[j-k];

            ll tmp = (ll)((n - i - j + k - 1) / k) * (ll)len;
            tmp += dpL[i] + dpR[j];
            // cout << i << ' ' << j << ' ' << tmp << endl;
            ans = min(ans, tmp);
        }
    }
    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...