답안 #93477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93477 2019-01-08T17:31:44 Z tincamatei 선물상자 (IOI15_boxes) C++14
10 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#include "boxes.h"

const int MAX_N = 10000000;

long long pref[1+MAX_N], suff[1+MAX_N];

long long cost(int i, int j, int l, int k, int n) {
  return pref[i] + suff[j] + (long long)(n - i - j + k - 1) / k * l;
}

long long delivery(int n, int k, int l, int p[]) {
  long long rez = 1LL << 60;

  if(n > 1000)
    return 0LL;

  for(int i = 1; i <= n; ++i) {
    if(i - k >= 0)
      pref[i] = pref[i - k];
    pref[i] = pref[i] + p[i - 1] * 2;
  }

  for(int i = 1; i <= n; ++i) {
    if(i - k >= 0)
      suff[i] = suff[i - k];
    suff[i] = suff[i] + (l - p[n - i]) * 2;
  }

  int lastup = n;
  for(int i = 0; i <= n; ++i) {
    lastup = std::min(lastup, n - i);
    while(lastup > 0 && cost(i, lastup - 1, l, k, n) <= cost(i, lastup, l, k, n))
      --lastup;
    rez = std::min(rez, cost(i, lastup, l, k, n));
  }

  return rez;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -