Submission #836350

# Submission time Handle Problem Language Result Execution time Memory
836350 2023-08-24T10:27:01 Z rainboy Jelly Flavours (IOI20_jelly) C++17
24 / 100
39 ms 528 KB
#include "jelly.h"
#include <vector>

using namespace std;

typedef vector<int> vi;

const int N = 2000, T = 10000;

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

int aa[N], bb[N];

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
		while (j < k)
			if (aa[ii[j]] == aa[i_])
				j++;
			else if (aa[ii[j]] < aa[i_]) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		sort(ii, l, i);
		l = k;
	}
}

int find_maximum_unique(int s_, int t_, vi aa_, vi bb_) {
	static int ii[N], dp[T + 1], tt[N + 1];
	int n = aa_.size();
	for (int i = 0; i < n; i++) {
		aa[i] = aa_[i], bb[i] = bb_[i];
		ii[i] = i;
	}
	sort(ii, 0, n);
	for (int t = 0; t <= t_; t++)
		dp[t] = s_ + 1;
	dp[0] = 0;
	tt[0] = 0;
	for (int i = 0; i < n; i++) {
		int i_ = ii[i];
		for (int t = t_; t >= 0; t--) {
			int s = dp[t];
			if (s > s_)
				continue;
			dp[t] = min(s + aa[i_], s_ + 1);
			if (t + bb[i_] <= t_)
				dp[t + bb[i_]] = min(dp[t + bb[i_]], s);
		}
		tt[i + 1] = t_ + 1;
		for (int t = 0; t <= t_; t++)
			if (dp[t] <= s_) {
				tt[i + 1] = t;
				break;
			}
	}
	int k = 0;
	for (int i = n; i >= 0; i--)
		if (tt[i] <= t_) {
			for (int j = i; j + 1 < n && bb[ii[j]] > bb[ii[j + 1]]; j++) {
				int tmp;
				tmp = ii[j], ii[j] = ii[j + 1], ii[j + 1] = tmp;
			}
			int t = tt[i], j = i;
			while (j < n && t + bb[ii[j]] <= t_)
				t += bb[ii[j++]];
			k = max(k, j);
		}
	return k;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '7', found: '6'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '7', found: '6'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '689', found: '65'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 308 KB Output is correct
2 Correct 24 ms 404 KB Output is correct
3 Correct 20 ms 400 KB Output is correct
4 Correct 19 ms 388 KB Output is correct
5 Correct 21 ms 392 KB Output is correct
6 Correct 20 ms 400 KB Output is correct
7 Correct 19 ms 308 KB Output is correct
8 Correct 20 ms 404 KB Output is correct
9 Correct 14 ms 340 KB Output is correct
10 Correct 15 ms 340 KB Output is correct
11 Correct 23 ms 400 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 18 ms 340 KB Output is correct
14 Correct 18 ms 296 KB Output is correct
15 Correct 29 ms 396 KB Output is correct
16 Correct 18 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 7 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 4 ms 380 KB Output is correct
22 Correct 35 ms 404 KB Output is correct
23 Correct 31 ms 388 KB Output is correct
24 Correct 15 ms 396 KB Output is correct
25 Correct 21 ms 400 KB Output is correct
26 Correct 25 ms 348 KB Output is correct
27 Correct 19 ms 404 KB Output is correct
28 Correct 18 ms 340 KB Output is correct
29 Correct 13 ms 340 KB Output is correct
30 Correct 17 ms 340 KB Output is correct
31 Correct 32 ms 400 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 26 ms 400 KB Output is correct
34 Correct 14 ms 384 KB Output is correct
35 Correct 17 ms 448 KB Output is correct
36 Correct 17 ms 340 KB Output is correct
37 Correct 1 ms 308 KB Output is correct
38 Correct 7 ms 376 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 3 ms 340 KB Output is correct
42 Correct 18 ms 404 KB Output is correct
43 Correct 30 ms 340 KB Output is correct
44 Correct 15 ms 340 KB Output is correct
45 Correct 21 ms 400 KB Output is correct
46 Correct 18 ms 340 KB Output is correct
47 Correct 18 ms 404 KB Output is correct
48 Correct 19 ms 404 KB Output is correct
49 Correct 15 ms 340 KB Output is correct
50 Correct 15 ms 404 KB Output is correct
51 Correct 18 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 22 ms 416 KB Output is correct
54 Correct 25 ms 340 KB Output is correct
55 Correct 17 ms 400 KB Output is correct
56 Correct 18 ms 396 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 4 ms 340 KB Output is correct
59 Correct 2 ms 340 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 3 ms 340 KB Output is correct
62 Correct 20 ms 340 KB Output is correct
63 Correct 35 ms 408 KB Output is correct
64 Correct 27 ms 392 KB Output is correct
65 Correct 22 ms 404 KB Output is correct
66 Correct 33 ms 384 KB Output is correct
67 Correct 18 ms 400 KB Output is correct
68 Correct 22 ms 340 KB Output is correct
69 Correct 13 ms 396 KB Output is correct
70 Correct 22 ms 392 KB Output is correct
71 Correct 18 ms 400 KB Output is correct
72 Correct 0 ms 340 KB Output is correct
73 Correct 18 ms 400 KB Output is correct
74 Correct 14 ms 400 KB Output is correct
75 Correct 16 ms 340 KB Output is correct
76 Correct 23 ms 528 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 3 ms 340 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 1 ms 340 KB Output is correct
81 Correct 3 ms 340 KB Output is correct
82 Correct 25 ms 404 KB Output is correct
83 Correct 17 ms 404 KB Output is correct
84 Correct 15 ms 392 KB Output is correct
85 Correct 22 ms 340 KB Output is correct
86 Correct 18 ms 380 KB Output is correct
87 Correct 26 ms 324 KB Output is correct
88 Correct 35 ms 396 KB Output is correct
89 Correct 14 ms 392 KB Output is correct
90 Correct 26 ms 340 KB Output is correct
91 Correct 21 ms 400 KB Output is correct
92 Correct 1 ms 340 KB Output is correct
93 Correct 18 ms 400 KB Output is correct
94 Correct 14 ms 340 KB Output is correct
95 Correct 32 ms 376 KB Output is correct
96 Correct 17 ms 400 KB Output is correct
97 Correct 1 ms 340 KB Output is correct
98 Correct 6 ms 372 KB Output is correct
99 Correct 4 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 372 KB Output is correct
2 Correct 17 ms 388 KB Output is correct
3 Correct 18 ms 404 KB Output is correct
4 Correct 25 ms 424 KB Output is correct
5 Correct 20 ms 392 KB Output is correct
6 Correct 19 ms 340 KB Output is correct
7 Correct 19 ms 404 KB Output is correct
8 Correct 35 ms 380 KB Output is correct
9 Correct 20 ms 396 KB Output is correct
10 Correct 22 ms 396 KB Output is correct
11 Correct 19 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 31 ms 400 KB Output is correct
14 Correct 17 ms 304 KB Output is correct
15 Correct 30 ms 396 KB Output is correct
16 Correct 18 ms 456 KB Output is correct
17 Correct 5 ms 340 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 17 ms 396 KB Output is correct
23 Correct 35 ms 312 KB Output is correct
24 Correct 21 ms 300 KB Output is correct
25 Correct 20 ms 388 KB Output is correct
26 Correct 24 ms 408 KB Output is correct
27 Correct 20 ms 352 KB Output is correct
28 Correct 21 ms 400 KB Output is correct
29 Correct 20 ms 400 KB Output is correct
30 Correct 22 ms 340 KB Output is correct
31 Correct 23 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 20 ms 404 KB Output is correct
34 Correct 16 ms 400 KB Output is correct
35 Correct 20 ms 340 KB Output is correct
36 Correct 17 ms 408 KB Output is correct
37 Correct 5 ms 372 KB Output is correct
38 Correct 4 ms 340 KB Output is correct
39 Correct 1 ms 304 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 3 ms 312 KB Output is correct
42 Correct 18 ms 396 KB Output is correct
43 Correct 23 ms 404 KB Output is correct
44 Correct 21 ms 296 KB Output is correct
45 Correct 22 ms 340 KB Output is correct
46 Correct 19 ms 300 KB Output is correct
47 Correct 19 ms 404 KB Output is correct
48 Correct 19 ms 400 KB Output is correct
49 Correct 20 ms 400 KB Output is correct
50 Correct 26 ms 400 KB Output is correct
51 Correct 21 ms 472 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 19 ms 304 KB Output is correct
54 Correct 16 ms 400 KB Output is correct
55 Correct 16 ms 404 KB Output is correct
56 Correct 25 ms 400 KB Output is correct
57 Correct 4 ms 340 KB Output is correct
58 Correct 5 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 5 ms 300 KB Output is correct
61 Correct 4 ms 340 KB Output is correct
62 Correct 18 ms 404 KB Output is correct
63 Correct 21 ms 400 KB Output is correct
64 Correct 24 ms 396 KB Output is correct
65 Correct 20 ms 340 KB Output is correct
66 Correct 19 ms 404 KB Output is correct
67 Correct 20 ms 304 KB Output is correct
68 Correct 18 ms 404 KB Output is correct
69 Correct 28 ms 404 KB Output is correct
70 Correct 23 ms 396 KB Output is correct
71 Correct 17 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 18 ms 340 KB Output is correct
74 Correct 30 ms 396 KB Output is correct
75 Correct 16 ms 396 KB Output is correct
76 Correct 25 ms 404 KB Output is correct
77 Correct 8 ms 340 KB Output is correct
78 Correct 5 ms 312 KB Output is correct
79 Correct 1 ms 340 KB Output is correct
80 Correct 1 ms 340 KB Output is correct
81 Correct 3 ms 340 KB Output is correct
82 Correct 28 ms 400 KB Output is correct
83 Correct 19 ms 304 KB Output is correct
84 Correct 20 ms 400 KB Output is correct
85 Correct 20 ms 388 KB Output is correct
86 Correct 20 ms 412 KB Output is correct
87 Correct 19 ms 408 KB Output is correct
88 Correct 19 ms 340 KB Output is correct
89 Correct 21 ms 396 KB Output is correct
90 Correct 39 ms 400 KB Output is correct
91 Correct 17 ms 396 KB Output is correct
92 Correct 1 ms 340 KB Output is correct
93 Correct 24 ms 404 KB Output is correct
94 Correct 16 ms 400 KB Output is correct
95 Correct 16 ms 396 KB Output is correct
96 Correct 18 ms 404 KB Output is correct
97 Correct 5 ms 340 KB Output is correct
98 Correct 6 ms 340 KB Output is correct
99 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '7', found: '6'
3 Halted 0 ms 0 KB -