Submission #23837

# Submission time Handle Problem Language Result Execution time Memory
23837 2017-05-26T13:50:31 Z Nirjhor Boxes with souvenirs (IOI15_boxes) C++14
100 / 100
723 ms 170972 KB
#include <bits/stdc++.h>
#include "boxes.h"

using namespace std;

vector <long long> costLeft;
vector <long long> costRight;

long long delivery (int N, int K, int L, int p[]) {
  int mid = L >> 1;
  for (int i = 0; i < N; ++i) {
  	if (p[i] > mid) {
  		costRight.push_back(2LL * (L - p[i]));
  	} else {
  		costLeft.push_back(2LL * p[i]);
  	}
  }
  reverse(costRight.begin(), costRight.end());
  int sizeLeft = (int) costLeft.size();
  int sizeRight = (int) costRight.size();
  for (int i = K; i < sizeLeft; ++i) {
  	costLeft[i] += costLeft[i - K];
  }
  for (int i = K; i < sizeRight; ++i) {
  	costRight[i] += costRight[i - K];
  }
  long long leftCost = sizeLeft ? costLeft[sizeLeft - 1] : 0;
  long long rightCost = sizeRight ? costRight[sizeRight - 1] : 0;
  long long ret = leftCost + rightCost;
  for (int i = 0; i <= K; ++i) {
  	int leftTaken = i, rightTaken = K - i;
  	long long left = leftTaken >= sizeLeft ? 0 : costLeft[sizeLeft - 1 - leftTaken];
  	long long right = rightTaken >= sizeRight ? 0 : costRight[sizeRight - 1 - rightTaken];
  	ret = min(ret, L + left + right);
  }
  return ret;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 276 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 404 KB Output is correct
# Verdict Execution time Memory 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 380 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 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 276 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 404 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 420 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 276 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 404 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 420 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 49 ms 14304 KB Output is correct
34 Correct 30 ms 16212 KB Output is correct
35 Correct 29 ms 16212 KB Output is correct
36 Correct 52 ms 12596 KB Output is correct
37 Correct 50 ms 12656 KB Output is correct
38 Correct 55 ms 14080 KB Output is correct
39 Correct 45 ms 14244 KB Output is correct
40 Correct 31 ms 14304 KB Output is correct
41 Correct 87 ms 12628 KB Output is correct
42 Correct 38 ms 12612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 276 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 404 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 420 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 49 ms 14304 KB Output is correct
34 Correct 30 ms 16212 KB Output is correct
35 Correct 29 ms 16212 KB Output is correct
36 Correct 52 ms 12596 KB Output is correct
37 Correct 50 ms 12656 KB Output is correct
38 Correct 55 ms 14080 KB Output is correct
39 Correct 45 ms 14244 KB Output is correct
40 Correct 31 ms 14304 KB Output is correct
41 Correct 87 ms 12628 KB Output is correct
42 Correct 38 ms 12612 KB Output is correct
43 Correct 555 ms 144504 KB Output is correct
44 Correct 248 ms 135616 KB Output is correct
45 Correct 310 ms 146092 KB Output is correct
46 Correct 541 ms 170920 KB Output is correct
47 Correct 723 ms 119908 KB Output is correct
48 Correct 520 ms 170944 KB Output is correct
49 Correct 491 ms 144368 KB Output is correct
50 Correct 351 ms 144396 KB Output is correct
51 Correct 533 ms 170972 KB Output is correct
52 Correct 355 ms 170960 KB Output is correct