#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++)
if(dp[i][bugA] <= y)
{
///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 |
21 ms |
21248 KB |
1st lines differ - on the 1st token, expected: '689', found: '65' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
76152 KB |
Output is correct |
2 |
Correct |
93 ms |
78072 KB |
Output is correct |
3 |
Correct |
96 ms |
78328 KB |
Output is correct |
4 |
Correct |
145 ms |
75128 KB |
Output is correct |
5 |
Correct |
148 ms |
77944 KB |
Output is correct |
6 |
Correct |
109 ms |
74872 KB |
Output is correct |
7 |
Correct |
90 ms |
77304 KB |
Output is correct |
8 |
Correct |
94 ms |
75256 KB |
Output is correct |
9 |
Correct |
145 ms |
75260 KB |
Output is correct |
10 |
Correct |
139 ms |
76408 KB |
Output is correct |
11 |
Correct |
11 ms |
12416 KB |
Output is correct |
12 |
Correct |
5 ms |
8064 KB |
Output is correct |
13 |
Correct |
7 ms |
9728 KB |
Output is correct |
14 |
Correct |
24 ms |
9728 KB |
Output is correct |
15 |
Correct |
17 ms |
12160 KB |
Output is correct |
16 |
Correct |
6 ms |
8832 KB |
Output is correct |
17 |
Correct |
94 ms |
78584 KB |
Output is correct |
18 |
Correct |
90 ms |
74872 KB |
Output is correct |
19 |
Correct |
116 ms |
76676 KB |
Output is correct |
20 |
Correct |
100 ms |
77176 KB |
Output is correct |
21 |
Correct |
103 ms |
76152 KB |
Output is correct |
22 |
Correct |
100 ms |
78072 KB |
Output is correct |
23 |
Correct |
93 ms |
78328 KB |
Output is correct |
24 |
Correct |
149 ms |
75000 KB |
Output is correct |
25 |
Correct |
142 ms |
77816 KB |
Output is correct |
26 |
Correct |
91 ms |
74976 KB |
Output is correct |
27 |
Correct |
91 ms |
77432 KB |
Output is correct |
28 |
Correct |
94 ms |
75384 KB |
Output is correct |
29 |
Correct |
142 ms |
75256 KB |
Output is correct |
30 |
Correct |
150 ms |
76280 KB |
Output is correct |
31 |
Correct |
14 ms |
12416 KB |
Output is correct |
32 |
Correct |
5 ms |
8064 KB |
Output is correct |
33 |
Correct |
7 ms |
9600 KB |
Output is correct |
34 |
Correct |
24 ms |
9728 KB |
Output is correct |
35 |
Correct |
18 ms |
12160 KB |
Output is correct |
36 |
Correct |
7 ms |
8832 KB |
Output is correct |
37 |
Correct |
98 ms |
78804 KB |
Output is correct |
38 |
Correct |
90 ms |
74872 KB |
Output is correct |
39 |
Correct |
120 ms |
76664 KB |
Output is correct |
40 |
Correct |
101 ms |
77176 KB |
Output is correct |
41 |
Correct |
92 ms |
76152 KB |
Output is correct |
42 |
Correct |
97 ms |
78044 KB |
Output is correct |
43 |
Correct |
97 ms |
78432 KB |
Output is correct |
44 |
Correct |
148 ms |
75056 KB |
Output is correct |
45 |
Correct |
147 ms |
77816 KB |
Output is correct |
46 |
Correct |
92 ms |
74872 KB |
Output is correct |
47 |
Correct |
91 ms |
77304 KB |
Output is correct |
48 |
Correct |
92 ms |
75256 KB |
Output is correct |
49 |
Correct |
142 ms |
75256 KB |
Output is correct |
50 |
Correct |
143 ms |
76280 KB |
Output is correct |
51 |
Correct |
11 ms |
12416 KB |
Output is correct |
52 |
Correct |
5 ms |
8064 KB |
Output is correct |
53 |
Correct |
7 ms |
9600 KB |
Output is correct |
54 |
Correct |
32 ms |
9728 KB |
Output is correct |
55 |
Correct |
18 ms |
12160 KB |
Output is correct |
56 |
Correct |
6 ms |
8832 KB |
Output is correct |
57 |
Correct |
95 ms |
78696 KB |
Output is correct |
58 |
Correct |
99 ms |
74900 KB |
Output is correct |
59 |
Correct |
116 ms |
76664 KB |
Output is correct |
60 |
Correct |
100 ms |
77176 KB |
Output is correct |
61 |
Correct |
90 ms |
76124 KB |
Output is correct |
62 |
Correct |
98 ms |
77944 KB |
Output is correct |
63 |
Correct |
99 ms |
78328 KB |
Output is correct |
64 |
Correct |
150 ms |
75000 KB |
Output is correct |
65 |
Correct |
150 ms |
77724 KB |
Output is correct |
66 |
Correct |
93 ms |
74972 KB |
Output is correct |
67 |
Correct |
95 ms |
77288 KB |
Output is correct |
68 |
Correct |
95 ms |
75256 KB |
Output is correct |
69 |
Correct |
144 ms |
75340 KB |
Output is correct |
70 |
Correct |
146 ms |
76384 KB |
Output is correct |
71 |
Correct |
12 ms |
12416 KB |
Output is correct |
72 |
Correct |
5 ms |
8168 KB |
Output is correct |
73 |
Correct |
8 ms |
9728 KB |
Output is correct |
74 |
Correct |
24 ms |
9628 KB |
Output is correct |
75 |
Correct |
19 ms |
12160 KB |
Output is correct |
76 |
Correct |
6 ms |
8832 KB |
Output is correct |
77 |
Correct |
93 ms |
78692 KB |
Output is correct |
78 |
Correct |
91 ms |
74872 KB |
Output is correct |
79 |
Correct |
121 ms |
76772 KB |
Output is correct |
80 |
Correct |
105 ms |
77176 KB |
Output is correct |
81 |
Correct |
95 ms |
76152 KB |
Output is correct |
82 |
Correct |
101 ms |
77944 KB |
Output is correct |
83 |
Correct |
95 ms |
78380 KB |
Output is correct |
84 |
Correct |
148 ms |
75128 KB |
Output is correct |
85 |
Correct |
153 ms |
77816 KB |
Output is correct |
86 |
Correct |
93 ms |
75000 KB |
Output is correct |
87 |
Correct |
92 ms |
77304 KB |
Output is correct |
88 |
Correct |
94 ms |
75256 KB |
Output is correct |
89 |
Correct |
143 ms |
75256 KB |
Output is correct |
90 |
Correct |
146 ms |
76408 KB |
Output is correct |
91 |
Correct |
12 ms |
12324 KB |
Output is correct |
92 |
Correct |
5 ms |
8064 KB |
Output is correct |
93 |
Correct |
7 ms |
9600 KB |
Output is correct |
94 |
Correct |
27 ms |
9728 KB |
Output is correct |
95 |
Correct |
18 ms |
12160 KB |
Output is correct |
96 |
Correct |
6 ms |
8832 KB |
Output is correct |
97 |
Correct |
96 ms |
78804 KB |
Output is correct |
98 |
Correct |
91 ms |
74896 KB |
Output is correct |
99 |
Correct |
118 ms |
76664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
95 ms |
77048 KB |
Output is correct |
2 |
Correct |
113 ms |
75256 KB |
Output is correct |
3 |
Correct |
93 ms |
77368 KB |
Output is correct |
4 |
Correct |
202 ms |
77012 KB |
Output is correct |
5 |
Correct |
190 ms |
74748 KB |
Output is correct |
6 |
Correct |
95 ms |
77056 KB |
Output is correct |
7 |
Correct |
96 ms |
78000 KB |
Output is correct |
8 |
Correct |
92 ms |
75168 KB |
Output is correct |
9 |
Correct |
193 ms |
77304 KB |
Output is correct |
10 |
Correct |
197 ms |
78424 KB |
Output is correct |
11 |
Correct |
13 ms |
11392 KB |
Output is correct |
12 |
Correct |
5 ms |
8320 KB |
Output is correct |
13 |
Correct |
32 ms |
22144 KB |
Output is correct |
14 |
Correct |
66 ms |
11776 KB |
Output is correct |
15 |
Correct |
88 ms |
22784 KB |
Output is correct |
16 |
Correct |
19 ms |
18304 KB |
Output is correct |
17 |
Correct |
100 ms |
78376 KB |
Output is correct |
18 |
Correct |
93 ms |
78200 KB |
Output is correct |
19 |
Correct |
146 ms |
77560 KB |
Output is correct |
20 |
Correct |
150 ms |
78328 KB |
Output is correct |
21 |
Correct |
92 ms |
77048 KB |
Output is correct |
22 |
Correct |
96 ms |
75256 KB |
Output is correct |
23 |
Correct |
95 ms |
77336 KB |
Output is correct |
24 |
Correct |
246 ms |
77016 KB |
Output is correct |
25 |
Correct |
189 ms |
74856 KB |
Output is correct |
26 |
Correct |
93 ms |
77104 KB |
Output is correct |
27 |
Correct |
100 ms |
78072 KB |
Output is correct |
28 |
Correct |
107 ms |
75128 KB |
Output is correct |
29 |
Correct |
193 ms |
77432 KB |
Output is correct |
30 |
Correct |
202 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 |
24 ms |
22144 KB |
Output is correct |
34 |
Correct |
111 ms |
11776 KB |
Output is correct |
35 |
Correct |
88 ms |
22784 KB |
Output is correct |
36 |
Correct |
20 ms |
18304 KB |
Output is correct |
37 |
Correct |
93 ms |
78328 KB |
Output is correct |
38 |
Correct |
92 ms |
78200 KB |
Output is correct |
39 |
Correct |
146 ms |
77560 KB |
Output is correct |
40 |
Correct |
151 ms |
78344 KB |
Output is correct |
41 |
Correct |
96 ms |
77128 KB |
Output is correct |
42 |
Correct |
96 ms |
75292 KB |
Output is correct |
43 |
Correct |
93 ms |
77304 KB |
Output is correct |
44 |
Correct |
200 ms |
77048 KB |
Output is correct |
45 |
Correct |
187 ms |
74860 KB |
Output is correct |
46 |
Correct |
95 ms |
77072 KB |
Output is correct |
47 |
Correct |
95 ms |
78072 KB |
Output is correct |
48 |
Correct |
97 ms |
75168 KB |
Output is correct |
49 |
Correct |
189 ms |
77300 KB |
Output is correct |
50 |
Correct |
194 ms |
78304 KB |
Output is correct |
51 |
Correct |
10 ms |
11392 KB |
Output is correct |
52 |
Correct |
5 ms |
8320 KB |
Output is correct |
53 |
Correct |
23 ms |
22144 KB |
Output is correct |
54 |
Correct |
69 ms |
11892 KB |
Output is correct |
55 |
Correct |
93 ms |
22812 KB |
Output is correct |
56 |
Correct |
24 ms |
18304 KB |
Output is correct |
57 |
Correct |
103 ms |
78316 KB |
Output is correct |
58 |
Correct |
92 ms |
78200 KB |
Output is correct |
59 |
Correct |
156 ms |
77560 KB |
Output is correct |
60 |
Correct |
154 ms |
78328 KB |
Output is correct |
61 |
Correct |
96 ms |
77048 KB |
Output is correct |
62 |
Correct |
93 ms |
75384 KB |
Output is correct |
63 |
Correct |
93 ms |
77364 KB |
Output is correct |
64 |
Correct |
199 ms |
76920 KB |
Output is correct |
65 |
Correct |
188 ms |
74872 KB |
Output is correct |
66 |
Correct |
92 ms |
77048 KB |
Output is correct |
67 |
Correct |
94 ms |
78072 KB |
Output is correct |
68 |
Correct |
92 ms |
75128 KB |
Output is correct |
69 |
Correct |
190 ms |
77436 KB |
Output is correct |
70 |
Correct |
202 ms |
78336 KB |
Output is correct |
71 |
Correct |
11 ms |
11392 KB |
Output is correct |
72 |
Correct |
5 ms |
8320 KB |
Output is correct |
73 |
Correct |
24 ms |
22144 KB |
Output is correct |
74 |
Correct |
68 ms |
11776 KB |
Output is correct |
75 |
Correct |
87 ms |
22784 KB |
Output is correct |
76 |
Correct |
22 ms |
18304 KB |
Output is correct |
77 |
Correct |
91 ms |
78336 KB |
Output is correct |
78 |
Correct |
90 ms |
78204 KB |
Output is correct |
79 |
Correct |
142 ms |
77688 KB |
Output is correct |
80 |
Correct |
147 ms |
78456 KB |
Output is correct |
81 |
Correct |
92 ms |
77048 KB |
Output is correct |
82 |
Correct |
110 ms |
75256 KB |
Output is correct |
83 |
Correct |
92 ms |
77304 KB |
Output is correct |
84 |
Correct |
193 ms |
76920 KB |
Output is correct |
85 |
Correct |
183 ms |
74744 KB |
Output is correct |
86 |
Correct |
94 ms |
77048 KB |
Output is correct |
87 |
Correct |
94 ms |
78072 KB |
Output is correct |
88 |
Correct |
93 ms |
75136 KB |
Output is correct |
89 |
Correct |
187 ms |
77340 KB |
Output is correct |
90 |
Correct |
200 ms |
78328 KB |
Output is correct |
91 |
Correct |
10 ms |
11392 KB |
Output is correct |
92 |
Correct |
5 ms |
8320 KB |
Output is correct |
93 |
Correct |
23 ms |
22144 KB |
Output is correct |
94 |
Correct |
65 ms |
11896 KB |
Output is correct |
95 |
Correct |
90 ms |
22784 KB |
Output is correct |
96 |
Correct |
20 ms |
18304 KB |
Output is correct |
97 |
Correct |
92 ms |
78328 KB |
Output is correct |
98 |
Correct |
90 ms |
78104 KB |
Output is correct |
99 |
Correct |
142 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 |
- |