제출 #146725

#제출 시각아이디문제언어결과실행 시간메모리
146725karma선물상자 (IOI15_boxes)C++11
10 / 100
3 ms376 KiB
#include <bits/stdc++.h>
#include "boxes.h"
#define ll       long long

using namespace std;

const int N = int(1e7);

ll f[N];
int mid, g;

ll delivery(int n, int k, int l, int pos[])
{
   mid = l >> 1;
   for(int i = 0; i < n; ++i) {
       if(pos[i] <= mid) {
          if(i >= k) f[i] = f[i - k] + min(2 * pos[i], l);
          else f[i] = min(2 * pos[i], l);
       } else {
           if(i >= k) f[i] = f[i - k] + min({l, 2 * (l - pos[i - k + 1]), 2 * pos[i]});
           else f[i] = min({l, 2 * (l - pos[i - k + 1]), 2 * pos[i]});
       }
   }
   return f[n - 1];
}

/*int _n, _k, _l, _pos[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen("test.inp", "r")) {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
    cin >> _n >> _k >> _l;
    for(int i = 0; i < _n; ++i) cin >> _pos[i];
    cout << delivery(_n, _k, _l, _pos);
}*/
#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...