#include "jelly.h"
#include <vector>
#include <algorithm>
const int NMAX = 2000;
const int XMAX = 10000;
const int INF = 10 * XMAX;
std::vector < std::pair <int, int> > pairs;
int dp[NMAX + 2][XMAX + 2];
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
int n = (int)a.size();
for(int i = 0; i < n; i++)
pairs.push_back({a[i], b[i]});
sort(pairs.begin(), pairs.end());
for(int i = 0; i <= n; i++)
for(int bugA = 0; bugA <= x; bugA++)
dp[i][bugA] = INF;
dp[0][0] = 0;
for(int i = 0; i < n; i++)
for(int bugA = 0; bugA <= x; bugA++)
{
///cumpar i + 1 din A
if(bugA + pairs[i].first <= x)
dp[i + 1][bugA + pairs[i].first] = std::min(dp[i + 1][bugA + pairs[i].first], dp[i][bugA]);
///cumpar i + 1 din B
if(dp[i][bugA] + pairs[i].second <= y)
dp[i + 1][bugA] = std::min(dp[i + 1][bugA], dp[i][bugA] + pairs[i].second);
}
std::vector <int> sufb;
int sol = 0;
for(int i = n; i >= 0; i--)
{
int minY = INF;
for(int bugA = 0; bugA <= x; bugA++)
minY = std::min(minY, dp[i][bugA]);
if(minY <= y) {
int placed = i; ///pref
if(i + 1 <= n)
sufb.push_back(pairs[i].second);
sort(sufb.begin(), sufb.end());
int remBudget = y - minY;
for(auto it : sufb)
if(remBudget >= it) {
remBudget -= it;
placed++;
} else
break;
sol = std::max(sol, placed);
}
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
21248 KB |
1st lines differ - on the 1st token, expected: '689', found: '65' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
135 ms |
76252 KB |
Output is correct |
2 |
Correct |
132 ms |
78072 KB |
Output is correct |
3 |
Correct |
136 ms |
78328 KB |
Output is correct |
4 |
Correct |
175 ms |
75000 KB |
Output is correct |
5 |
Correct |
174 ms |
77944 KB |
Output is correct |
6 |
Correct |
129 ms |
75000 KB |
Output is correct |
7 |
Correct |
130 ms |
77304 KB |
Output is correct |
8 |
Correct |
133 ms |
75256 KB |
Output is correct |
9 |
Correct |
181 ms |
75256 KB |
Output is correct |
10 |
Correct |
179 ms |
76408 KB |
Output is correct |
11 |
Correct |
13 ms |
12416 KB |
Output is correct |
12 |
Correct |
5 ms |
8064 KB |
Output is correct |
13 |
Correct |
8 ms |
9600 KB |
Output is correct |
14 |
Correct |
25 ms |
9728 KB |
Output is correct |
15 |
Correct |
20 ms |
12160 KB |
Output is correct |
16 |
Correct |
6 ms |
8832 KB |
Output is correct |
17 |
Correct |
136 ms |
78720 KB |
Output is correct |
18 |
Correct |
131 ms |
74912 KB |
Output is correct |
19 |
Correct |
179 ms |
76664 KB |
Output is correct |
20 |
Correct |
160 ms |
77176 KB |
Output is correct |
21 |
Correct |
130 ms |
76152 KB |
Output is correct |
22 |
Correct |
132 ms |
78088 KB |
Output is correct |
23 |
Correct |
137 ms |
78412 KB |
Output is correct |
24 |
Correct |
175 ms |
75128 KB |
Output is correct |
25 |
Correct |
181 ms |
77944 KB |
Output is correct |
26 |
Correct |
134 ms |
75068 KB |
Output is correct |
27 |
Correct |
136 ms |
77304 KB |
Output is correct |
28 |
Correct |
133 ms |
75352 KB |
Output is correct |
29 |
Correct |
177 ms |
75256 KB |
Output is correct |
30 |
Correct |
174 ms |
76420 KB |
Output is correct |
31 |
Correct |
13 ms |
12416 KB |
Output is correct |
32 |
Correct |
5 ms |
8064 KB |
Output is correct |
33 |
Correct |
8 ms |
9600 KB |
Output is correct |
34 |
Correct |
25 ms |
9728 KB |
Output is correct |
35 |
Correct |
20 ms |
12160 KB |
Output is correct |
36 |
Correct |
6 ms |
8832 KB |
Output is correct |
37 |
Correct |
134 ms |
78712 KB |
Output is correct |
38 |
Correct |
132 ms |
74908 KB |
Output is correct |
39 |
Correct |
175 ms |
76792 KB |
Output is correct |
40 |
Correct |
163 ms |
77304 KB |
Output is correct |
41 |
Correct |
130 ms |
76280 KB |
Output is correct |
42 |
Correct |
131 ms |
78072 KB |
Output is correct |
43 |
Correct |
134 ms |
78328 KB |
Output is correct |
44 |
Correct |
175 ms |
75128 KB |
Output is correct |
45 |
Correct |
179 ms |
77816 KB |
Output is correct |
46 |
Correct |
130 ms |
74872 KB |
Output is correct |
47 |
Correct |
132 ms |
77304 KB |
Output is correct |
48 |
Correct |
139 ms |
75384 KB |
Output is correct |
49 |
Correct |
180 ms |
75256 KB |
Output is correct |
50 |
Correct |
173 ms |
76280 KB |
Output is correct |
51 |
Correct |
13 ms |
12416 KB |
Output is correct |
52 |
Correct |
5 ms |
8064 KB |
Output is correct |
53 |
Correct |
8 ms |
9600 KB |
Output is correct |
54 |
Correct |
27 ms |
9728 KB |
Output is correct |
55 |
Correct |
20 ms |
12160 KB |
Output is correct |
56 |
Correct |
7 ms |
8832 KB |
Output is correct |
57 |
Correct |
133 ms |
78640 KB |
Output is correct |
58 |
Correct |
132 ms |
75000 KB |
Output is correct |
59 |
Correct |
165 ms |
76664 KB |
Output is correct |
60 |
Correct |
160 ms |
77184 KB |
Output is correct |
61 |
Correct |
130 ms |
76280 KB |
Output is correct |
62 |
Correct |
130 ms |
78072 KB |
Output is correct |
63 |
Correct |
135 ms |
78328 KB |
Output is correct |
64 |
Correct |
174 ms |
75056 KB |
Output is correct |
65 |
Correct |
182 ms |
77836 KB |
Output is correct |
66 |
Correct |
129 ms |
74872 KB |
Output is correct |
67 |
Correct |
131 ms |
77364 KB |
Output is correct |
68 |
Correct |
134 ms |
75384 KB |
Output is correct |
69 |
Correct |
175 ms |
75256 KB |
Output is correct |
70 |
Correct |
171 ms |
76280 KB |
Output is correct |
71 |
Correct |
14 ms |
12416 KB |
Output is correct |
72 |
Correct |
5 ms |
8064 KB |
Output is correct |
73 |
Correct |
10 ms |
9600 KB |
Output is correct |
74 |
Correct |
25 ms |
9728 KB |
Output is correct |
75 |
Correct |
20 ms |
12160 KB |
Output is correct |
76 |
Correct |
7 ms |
8832 KB |
Output is correct |
77 |
Correct |
132 ms |
78700 KB |
Output is correct |
78 |
Correct |
133 ms |
74872 KB |
Output is correct |
79 |
Correct |
174 ms |
76792 KB |
Output is correct |
80 |
Correct |
159 ms |
77180 KB |
Output is correct |
81 |
Correct |
129 ms |
76280 KB |
Output is correct |
82 |
Correct |
140 ms |
78200 KB |
Output is correct |
83 |
Correct |
148 ms |
78328 KB |
Output is correct |
84 |
Correct |
178 ms |
75000 KB |
Output is correct |
85 |
Correct |
175 ms |
77944 KB |
Output is correct |
86 |
Correct |
133 ms |
75000 KB |
Output is correct |
87 |
Correct |
131 ms |
77304 KB |
Output is correct |
88 |
Correct |
134 ms |
75260 KB |
Output is correct |
89 |
Correct |
173 ms |
75256 KB |
Output is correct |
90 |
Correct |
174 ms |
76280 KB |
Output is correct |
91 |
Correct |
13 ms |
12416 KB |
Output is correct |
92 |
Correct |
5 ms |
8064 KB |
Output is correct |
93 |
Correct |
9 ms |
9600 KB |
Output is correct |
94 |
Correct |
27 ms |
9856 KB |
Output is correct |
95 |
Correct |
20 ms |
12160 KB |
Output is correct |
96 |
Correct |
6 ms |
8832 KB |
Output is correct |
97 |
Correct |
132 ms |
78584 KB |
Output is correct |
98 |
Correct |
128 ms |
74872 KB |
Output is correct |
99 |
Correct |
171 ms |
76664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
151 ms |
77176 KB |
Output is correct |
2 |
Correct |
132 ms |
75256 KB |
Output is correct |
3 |
Correct |
130 ms |
77304 KB |
Output is correct |
4 |
Correct |
247 ms |
77048 KB |
Output is correct |
5 |
Correct |
219 ms |
74744 KB |
Output is correct |
6 |
Correct |
130 ms |
77176 KB |
Output is correct |
7 |
Correct |
133 ms |
78072 KB |
Output is correct |
8 |
Correct |
129 ms |
75128 KB |
Output is correct |
9 |
Correct |
227 ms |
77364 KB |
Output is correct |
10 |
Correct |
235 ms |
78456 KB |
Output is correct |
11 |
Correct |
13 ms |
11520 KB |
Output is correct |
12 |
Correct |
5 ms |
8320 KB |
Output is correct |
13 |
Correct |
30 ms |
22272 KB |
Output is correct |
14 |
Correct |
68 ms |
11776 KB |
Output is correct |
15 |
Correct |
95 ms |
22784 KB |
Output is correct |
16 |
Correct |
23 ms |
18304 KB |
Output is correct |
17 |
Correct |
150 ms |
78340 KB |
Output is correct |
18 |
Correct |
147 ms |
78200 KB |
Output is correct |
19 |
Correct |
214 ms |
77680 KB |
Output is correct |
20 |
Correct |
220 ms |
78376 KB |
Output is correct |
21 |
Correct |
154 ms |
77176 KB |
Output is correct |
22 |
Correct |
133 ms |
75384 KB |
Output is correct |
23 |
Correct |
132 ms |
77312 KB |
Output is correct |
24 |
Correct |
234 ms |
77016 KB |
Output is correct |
25 |
Correct |
223 ms |
74872 KB |
Output is correct |
26 |
Correct |
129 ms |
77176 KB |
Output is correct |
27 |
Correct |
132 ms |
78072 KB |
Output is correct |
28 |
Correct |
140 ms |
75128 KB |
Output is correct |
29 |
Correct |
225 ms |
77432 KB |
Output is correct |
30 |
Correct |
235 ms |
78328 KB |
Output is correct |
31 |
Correct |
12 ms |
11392 KB |
Output is correct |
32 |
Correct |
5 ms |
8320 KB |
Output is correct |
33 |
Correct |
28 ms |
22144 KB |
Output is correct |
34 |
Correct |
69 ms |
11776 KB |
Output is correct |
35 |
Correct |
92 ms |
22812 KB |
Output is correct |
36 |
Correct |
23 ms |
18304 KB |
Output is correct |
37 |
Correct |
148 ms |
78456 KB |
Output is correct |
38 |
Correct |
147 ms |
78332 KB |
Output is correct |
39 |
Correct |
202 ms |
77560 KB |
Output is correct |
40 |
Correct |
205 ms |
78328 KB |
Output is correct |
41 |
Correct |
153 ms |
77048 KB |
Output is correct |
42 |
Correct |
130 ms |
75256 KB |
Output is correct |
43 |
Correct |
123 ms |
77304 KB |
Output is correct |
44 |
Correct |
232 ms |
77048 KB |
Output is correct |
45 |
Correct |
219 ms |
74856 KB |
Output is correct |
46 |
Correct |
175 ms |
77048 KB |
Output is correct |
47 |
Correct |
136 ms |
78072 KB |
Output is correct |
48 |
Correct |
131 ms |
75256 KB |
Output is correct |
49 |
Correct |
226 ms |
77304 KB |
Output is correct |
50 |
Correct |
228 ms |
78328 KB |
Output is correct |
51 |
Correct |
12 ms |
11392 KB |
Output is correct |
52 |
Correct |
5 ms |
8320 KB |
Output is correct |
53 |
Correct |
29 ms |
22144 KB |
Output is correct |
54 |
Correct |
68 ms |
11776 KB |
Output is correct |
55 |
Correct |
91 ms |
22784 KB |
Output is correct |
56 |
Correct |
22 ms |
18304 KB |
Output is correct |
57 |
Correct |
151 ms |
78456 KB |
Output is correct |
58 |
Correct |
146 ms |
78200 KB |
Output is correct |
59 |
Correct |
209 ms |
77560 KB |
Output is correct |
60 |
Correct |
217 ms |
78456 KB |
Output is correct |
61 |
Correct |
150 ms |
77048 KB |
Output is correct |
62 |
Correct |
133 ms |
75256 KB |
Output is correct |
63 |
Correct |
129 ms |
77304 KB |
Output is correct |
64 |
Correct |
236 ms |
77176 KB |
Output is correct |
65 |
Correct |
220 ms |
74744 KB |
Output is correct |
66 |
Correct |
130 ms |
77184 KB |
Output is correct |
67 |
Correct |
135 ms |
78072 KB |
Output is correct |
68 |
Correct |
131 ms |
75128 KB |
Output is correct |
69 |
Correct |
220 ms |
77432 KB |
Output is correct |
70 |
Correct |
236 ms |
78456 KB |
Output is correct |
71 |
Correct |
12 ms |
11392 KB |
Output is correct |
72 |
Correct |
5 ms |
8320 KB |
Output is correct |
73 |
Correct |
29 ms |
22144 KB |
Output is correct |
74 |
Correct |
68 ms |
11896 KB |
Output is correct |
75 |
Correct |
92 ms |
22808 KB |
Output is correct |
76 |
Correct |
23 ms |
18304 KB |
Output is correct |
77 |
Correct |
150 ms |
78484 KB |
Output is correct |
78 |
Correct |
146 ms |
78200 KB |
Output is correct |
79 |
Correct |
211 ms |
77756 KB |
Output is correct |
80 |
Correct |
217 ms |
78456 KB |
Output is correct |
81 |
Correct |
150 ms |
77048 KB |
Output is correct |
82 |
Correct |
135 ms |
75256 KB |
Output is correct |
83 |
Correct |
129 ms |
77368 KB |
Output is correct |
84 |
Correct |
235 ms |
77112 KB |
Output is correct |
85 |
Correct |
222 ms |
74752 KB |
Output is correct |
86 |
Correct |
129 ms |
77172 KB |
Output is correct |
87 |
Correct |
130 ms |
78200 KB |
Output is correct |
88 |
Correct |
132 ms |
75128 KB |
Output is correct |
89 |
Correct |
224 ms |
77416 KB |
Output is correct |
90 |
Correct |
234 ms |
78476 KB |
Output is correct |
91 |
Correct |
12 ms |
11392 KB |
Output is correct |
92 |
Correct |
6 ms |
8320 KB |
Output is correct |
93 |
Correct |
36 ms |
22144 KB |
Output is correct |
94 |
Correct |
66 ms |
11776 KB |
Output is correct |
95 |
Correct |
93 ms |
22904 KB |
Output is correct |
96 |
Correct |
22 ms |
18304 KB |
Output is correct |
97 |
Correct |
148 ms |
78376 KB |
Output is correct |
98 |
Correct |
147 ms |
78328 KB |
Output is correct |
99 |
Correct |
212 ms |
77688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |