Submission #795116

#TimeUsernameProblemLanguageResultExecution timeMemory
795116Ronin13Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms340 KiB
#include "boxes.h"
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

long long delivery(int N, int K, int L, int p[]) {
    ll a[N], b[N];
    int n= N;
    for(int i = 0; i < n; i++){
        if(i < K) a[i] = p[i];
        else a[i] = a[i - K] + p[i];
    }
    for(int i = n - 1; i >= 0; i--){
        if(i + K < n) b[i] = b[i + K] + L - p[i];
        else b[i] = L - p[i];
    }
    ll ans = min(a[n - 1], b[0]);
    for(int i = 0; i < n - 1; i++){
        ans = min(ans, a[i] + b[i + 1]);
    }
    return ans * 2;
}
#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...