#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005, MAX = 1e4+5;
int dp[MAXN][MAX], dp2[MAXN][MAX];
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size();
sort(a.begin(),a.end());
int ans = 0;
for(int j = 1; j <= n; j++)
for(int k = 0; k <= x; k++){
if(k < a[j-1])dp[j][k] = dp[j-1][k]+b[j-1];
else dp[j][k] = min(dp[j-1][k]+b[j-1], dp[j-1][k-a[j-1]]);
}
for(int j = n; j >= 1; j--)
for(int k = 0; k <= y; k++){
if(k < b[j-1])dp2[j][k] = dp2[j+1][k];
else dp2[j][k] = max(dp2[j+1][k], dp2[j+1][k-b[j-1]]+1);
}
for(int i = 0; i <= n; i++){
if(y < dp[i][x])continue;
int r = y - dp[i][x];
ans = max(i+dp2[i+1][r], ans);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 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 |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 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 |
63 ms |
152732 KB |
1st lines differ - on the 1st token, expected: '689', found: '688' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
152148 KB |
Output is correct |
2 |
Correct |
52 ms |
155728 KB |
Output is correct |
3 |
Correct |
53 ms |
156232 KB |
Output is correct |
4 |
Correct |
64 ms |
150432 KB |
Output is correct |
5 |
Correct |
64 ms |
155220 KB |
Output is correct |
6 |
Correct |
55 ms |
150476 KB |
Output is correct |
7 |
Correct |
52 ms |
154964 KB |
Output is correct |
8 |
Correct |
48 ms |
150888 KB |
Output is correct |
9 |
Correct |
60 ms |
150864 KB |
Output is correct |
10 |
Correct |
63 ms |
153940 KB |
Output is correct |
11 |
Correct |
35 ms |
152916 KB |
Output is correct |
12 |
Correct |
16 ms |
148316 KB |
Output is correct |
13 |
Correct |
36 ms |
153424 KB |
Output is correct |
14 |
Correct |
41 ms |
152400 KB |
Output is correct |
15 |
Correct |
41 ms |
152912 KB |
Output is correct |
16 |
Correct |
38 ms |
150100 KB |
Output is correct |
17 |
Correct |
36 ms |
156552 KB |
Output is correct |
18 |
Correct |
36 ms |
149840 KB |
Output is correct |
19 |
Correct |
44 ms |
153948 KB |
Output is correct |
20 |
Correct |
39 ms |
153940 KB |
Output is correct |
21 |
Correct |
36 ms |
152148 KB |
Output is correct |
22 |
Correct |
52 ms |
155632 KB |
Output is correct |
23 |
Correct |
52 ms |
156344 KB |
Output is correct |
24 |
Correct |
69 ms |
150372 KB |
Output is correct |
25 |
Correct |
67 ms |
155224 KB |
Output is correct |
26 |
Correct |
55 ms |
150388 KB |
Output is correct |
27 |
Correct |
54 ms |
154960 KB |
Output is correct |
28 |
Correct |
48 ms |
150732 KB |
Output is correct |
29 |
Correct |
61 ms |
150732 KB |
Output is correct |
30 |
Correct |
63 ms |
153744 KB |
Output is correct |
31 |
Correct |
36 ms |
152924 KB |
Output is correct |
32 |
Correct |
16 ms |
148380 KB |
Output is correct |
33 |
Correct |
36 ms |
153428 KB |
Output is correct |
34 |
Correct |
40 ms |
152404 KB |
Output is correct |
35 |
Correct |
41 ms |
152916 KB |
Output is correct |
36 |
Correct |
33 ms |
149844 KB |
Output is correct |
37 |
Correct |
36 ms |
156644 KB |
Output is correct |
38 |
Correct |
36 ms |
149840 KB |
Output is correct |
39 |
Correct |
43 ms |
153824 KB |
Output is correct |
40 |
Correct |
40 ms |
153936 KB |
Output is correct |
41 |
Correct |
37 ms |
152144 KB |
Output is correct |
42 |
Correct |
51 ms |
155732 KB |
Output is correct |
43 |
Correct |
52 ms |
156244 KB |
Output is correct |
44 |
Correct |
70 ms |
150408 KB |
Output is correct |
45 |
Correct |
72 ms |
155216 KB |
Output is correct |
46 |
Correct |
53 ms |
150492 KB |
Output is correct |
47 |
Correct |
56 ms |
154792 KB |
Output is correct |
48 |
Correct |
48 ms |
150764 KB |
Output is correct |
49 |
Correct |
67 ms |
150608 KB |
Output is correct |
50 |
Correct |
63 ms |
153936 KB |
Output is correct |
51 |
Correct |
38 ms |
152924 KB |
Output is correct |
52 |
Correct |
16 ms |
148316 KB |
Output is correct |
53 |
Correct |
36 ms |
153316 KB |
Output is correct |
54 |
Correct |
41 ms |
152408 KB |
Output is correct |
55 |
Correct |
40 ms |
152732 KB |
Output is correct |
56 |
Correct |
36 ms |
149636 KB |
Output is correct |
57 |
Correct |
35 ms |
156600 KB |
Output is correct |
58 |
Correct |
36 ms |
149848 KB |
Output is correct |
59 |
Correct |
43 ms |
153948 KB |
Output is correct |
60 |
Correct |
38 ms |
153940 KB |
Output is correct |
61 |
Correct |
36 ms |
152144 KB |
Output is correct |
62 |
Correct |
52 ms |
155728 KB |
Output is correct |
63 |
Correct |
52 ms |
156240 KB |
Output is correct |
64 |
Correct |
63 ms |
150608 KB |
Output is correct |
65 |
Correct |
64 ms |
155296 KB |
Output is correct |
66 |
Correct |
54 ms |
150304 KB |
Output is correct |
67 |
Correct |
52 ms |
154808 KB |
Output is correct |
68 |
Correct |
48 ms |
150868 KB |
Output is correct |
69 |
Correct |
60 ms |
150608 KB |
Output is correct |
70 |
Correct |
63 ms |
153940 KB |
Output is correct |
71 |
Correct |
34 ms |
153112 KB |
Output is correct |
72 |
Correct |
16 ms |
148316 KB |
Output is correct |
73 |
Correct |
36 ms |
153428 KB |
Output is correct |
74 |
Correct |
40 ms |
152548 KB |
Output is correct |
75 |
Correct |
41 ms |
152912 KB |
Output is correct |
76 |
Correct |
34 ms |
149724 KB |
Output is correct |
77 |
Correct |
37 ms |
156500 KB |
Output is correct |
78 |
Correct |
37 ms |
149892 KB |
Output is correct |
79 |
Correct |
46 ms |
154248 KB |
Output is correct |
80 |
Correct |
40 ms |
153936 KB |
Output is correct |
81 |
Correct |
38 ms |
152144 KB |
Output is correct |
82 |
Correct |
52 ms |
155544 KB |
Output is correct |
83 |
Correct |
52 ms |
156240 KB |
Output is correct |
84 |
Correct |
68 ms |
150476 KB |
Output is correct |
85 |
Correct |
65 ms |
155216 KB |
Output is correct |
86 |
Correct |
53 ms |
150352 KB |
Output is correct |
87 |
Correct |
53 ms |
154964 KB |
Output is correct |
88 |
Correct |
48 ms |
150712 KB |
Output is correct |
89 |
Correct |
60 ms |
150640 KB |
Output is correct |
90 |
Correct |
62 ms |
153936 KB |
Output is correct |
91 |
Correct |
34 ms |
152860 KB |
Output is correct |
92 |
Correct |
16 ms |
148316 KB |
Output is correct |
93 |
Correct |
36 ms |
153436 KB |
Output is correct |
94 |
Correct |
40 ms |
152408 KB |
Output is correct |
95 |
Correct |
44 ms |
152916 KB |
Output is correct |
96 |
Correct |
34 ms |
149840 KB |
Output is correct |
97 |
Correct |
36 ms |
156500 KB |
Output is correct |
98 |
Correct |
36 ms |
149960 KB |
Output is correct |
99 |
Correct |
43 ms |
153936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
153936 KB |
1st lines differ - on the 1st token, expected: '154', found: '195' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '7', found: '6' |
3 |
Halted |
0 ms |
0 KB |
- |