#include "jelly.h"
#include <cstdio>
#include <cassert>
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int find_maximum_unique(int x, int y, std::vector<int> arr, std::vector<int> brr) {
int n = arr.size();
bool ok=true;
bool okay=true;
for (int i =0;i<n;++i){
if (arr[i]!=brr[i]){
ok=false;
}
if (i>0){
if (brr[i]!=brr[i-1])okay=false;
}
}
if (okay){
vector<pair<int,int>>crr(n);
for (int i=0;i<n;++i){
crr[i]={arr[i],brr[i]};
}
sort(crr.begin(),crr.end());
int ans=0;
n--;
while(n>=0){
if (y-crr[n].second>=0){
y-=crr[n].second;
--n;
ans++;
}
else break;
}
for (int i =0;i<=n;++i){
if (x-crr[i].first<0)break;
x-=crr[i].first;
ans++;
}
return ans;
}
if (!ok){
vector<pair<int,int>>crr;
for(int i =0;i<n;++i){
crr.push_back({arr[i],brr[i]});
}
sort(crr.begin(),crr.end());
vector<pair<int,int>>dp(x+1,{-1,-1});
dp[0]={0,0};
for (int i =0;i<n;++i){
for (int j =x;j>=0;--j){
if (dp[j].first==-1)continue;
if (j+crr[i].first<=x){
dp[j+crr[i].first].first = dp[j].first+1;
dp[j+crr[i].first].second=dp[j].second;
}
if (dp[j].second+crr[i].second<=y){
dp[j].second=dp[j].second+crr[i].second;
dp[j].first=dp[j].first+1;
}
}
}
int ans=0;
for (int i =0;i<=x;++i){
if (dp[i].second<=y)
ans=max(ans,dp[i].first);
}
return ans;
}
else {
int dp1[n+1][x+y+1];
memset(dp1,0,sizeof dp1);
for (int i =1;i<=n;++i){
for (int j =0;j<=x+y;++j){
dp1[i][j] = max({(j-arr[i-1]>=0)?dp1[i-1][j-arr[i-1]]+1:0,dp1[i][j],dp1[i-1][j]});
}
}
return dp1[n][x+y];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
284 KB |
1st lines differ - on the 1st token, expected: '5', found: '4' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
284 KB |
1st lines differ - on the 1st token, expected: '5', found: '4' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
332 KB |
1st lines differ - on the 1st token, expected: '689', found: '644' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
240 KB |
Output is correct |
20 |
Correct |
1 ms |
352 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
332 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
332 KB |
Output is correct |
41 |
Correct |
1 ms |
332 KB |
Output is correct |
42 |
Correct |
2 ms |
332 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
1 ms |
332 KB |
Output is correct |
45 |
Correct |
1 ms |
332 KB |
Output is correct |
46 |
Correct |
1 ms |
332 KB |
Output is correct |
47 |
Correct |
2 ms |
332 KB |
Output is correct |
48 |
Correct |
1 ms |
332 KB |
Output is correct |
49 |
Correct |
1 ms |
332 KB |
Output is correct |
50 |
Correct |
1 ms |
332 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
332 KB |
Output is correct |
53 |
Correct |
1 ms |
332 KB |
Output is correct |
54 |
Correct |
1 ms |
332 KB |
Output is correct |
55 |
Correct |
1 ms |
332 KB |
Output is correct |
56 |
Correct |
1 ms |
332 KB |
Output is correct |
57 |
Correct |
1 ms |
332 KB |
Output is correct |
58 |
Correct |
1 ms |
332 KB |
Output is correct |
59 |
Correct |
1 ms |
332 KB |
Output is correct |
60 |
Correct |
1 ms |
332 KB |
Output is correct |
61 |
Correct |
1 ms |
332 KB |
Output is correct |
62 |
Correct |
1 ms |
332 KB |
Output is correct |
63 |
Correct |
1 ms |
332 KB |
Output is correct |
64 |
Correct |
1 ms |
332 KB |
Output is correct |
65 |
Correct |
1 ms |
332 KB |
Output is correct |
66 |
Correct |
1 ms |
204 KB |
Output is correct |
67 |
Correct |
1 ms |
332 KB |
Output is correct |
68 |
Correct |
1 ms |
204 KB |
Output is correct |
69 |
Correct |
1 ms |
332 KB |
Output is correct |
70 |
Correct |
1 ms |
204 KB |
Output is correct |
71 |
Correct |
1 ms |
332 KB |
Output is correct |
72 |
Correct |
1 ms |
332 KB |
Output is correct |
73 |
Correct |
1 ms |
332 KB |
Output is correct |
74 |
Correct |
1 ms |
332 KB |
Output is correct |
75 |
Correct |
1 ms |
204 KB |
Output is correct |
76 |
Correct |
1 ms |
204 KB |
Output is correct |
77 |
Correct |
1 ms |
332 KB |
Output is correct |
78 |
Correct |
2 ms |
332 KB |
Output is correct |
79 |
Correct |
1 ms |
332 KB |
Output is correct |
80 |
Correct |
1 ms |
332 KB |
Output is correct |
81 |
Correct |
1 ms |
204 KB |
Output is correct |
82 |
Correct |
1 ms |
332 KB |
Output is correct |
83 |
Correct |
1 ms |
332 KB |
Output is correct |
84 |
Correct |
1 ms |
332 KB |
Output is correct |
85 |
Correct |
2 ms |
332 KB |
Output is correct |
86 |
Correct |
1 ms |
332 KB |
Output is correct |
87 |
Correct |
1 ms |
332 KB |
Output is correct |
88 |
Correct |
1 ms |
332 KB |
Output is correct |
89 |
Correct |
1 ms |
204 KB |
Output is correct |
90 |
Correct |
1 ms |
332 KB |
Output is correct |
91 |
Correct |
1 ms |
332 KB |
Output is correct |
92 |
Correct |
1 ms |
204 KB |
Output is correct |
93 |
Correct |
2 ms |
332 KB |
Output is correct |
94 |
Correct |
1 ms |
332 KB |
Output is correct |
95 |
Correct |
1 ms |
332 KB |
Output is correct |
96 |
Correct |
1 ms |
332 KB |
Output is correct |
97 |
Correct |
1 ms |
204 KB |
Output is correct |
98 |
Correct |
1 ms |
204 KB |
Output is correct |
99 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
102 ms |
79400 KB |
Output is correct |
2 |
Correct |
168 ms |
141228 KB |
Output is correct |
3 |
Correct |
157 ms |
140264 KB |
Output is correct |
4 |
Correct |
184 ms |
147852 KB |
Output is correct |
5 |
Correct |
159 ms |
143668 KB |
Output is correct |
6 |
Correct |
156 ms |
145488 KB |
Output is correct |
7 |
Correct |
159 ms |
147012 KB |
Output is correct |
8 |
Correct |
163 ms |
143428 KB |
Output is correct |
9 |
Correct |
155 ms |
142232 KB |
Output is correct |
10 |
Correct |
197 ms |
152108 KB |
Output is correct |
11 |
Correct |
90 ms |
74252 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
94 ms |
87852 KB |
Output is correct |
14 |
Correct |
87 ms |
78144 KB |
Output is correct |
15 |
Correct |
107 ms |
84536 KB |
Output is correct |
16 |
Correct |
105 ms |
78148 KB |
Output is correct |
17 |
Correct |
97 ms |
85568 KB |
Output is correct |
18 |
Correct |
97 ms |
85068 KB |
Output is correct |
19 |
Correct |
91 ms |
76020 KB |
Output is correct |
20 |
Correct |
96 ms |
77068 KB |
Output is correct |
21 |
Correct |
91 ms |
79348 KB |
Output is correct |
22 |
Correct |
152 ms |
141224 KB |
Output is correct |
23 |
Correct |
149 ms |
140228 KB |
Output is correct |
24 |
Correct |
161 ms |
147852 KB |
Output is correct |
25 |
Correct |
190 ms |
143664 KB |
Output is correct |
26 |
Correct |
156 ms |
145476 KB |
Output is correct |
27 |
Correct |
156 ms |
147032 KB |
Output is correct |
28 |
Correct |
157 ms |
143432 KB |
Output is correct |
29 |
Correct |
158 ms |
142228 KB |
Output is correct |
30 |
Correct |
174 ms |
152204 KB |
Output is correct |
31 |
Correct |
86 ms |
74308 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
95 ms |
87960 KB |
Output is correct |
34 |
Correct |
90 ms |
78032 KB |
Output is correct |
35 |
Correct |
92 ms |
84512 KB |
Output is correct |
36 |
Correct |
85 ms |
78000 KB |
Output is correct |
37 |
Correct |
106 ms |
85572 KB |
Output is correct |
38 |
Correct |
94 ms |
85132 KB |
Output is correct |
39 |
Correct |
102 ms |
76056 KB |
Output is correct |
40 |
Correct |
109 ms |
77100 KB |
Output is correct |
41 |
Correct |
94 ms |
79416 KB |
Output is correct |
42 |
Correct |
152 ms |
141244 KB |
Output is correct |
43 |
Correct |
150 ms |
140340 KB |
Output is correct |
44 |
Correct |
168 ms |
147856 KB |
Output is correct |
45 |
Correct |
167 ms |
143668 KB |
Output is correct |
46 |
Correct |
171 ms |
145600 KB |
Output is correct |
47 |
Correct |
161 ms |
146800 KB |
Output is correct |
48 |
Correct |
167 ms |
143520 KB |
Output is correct |
49 |
Correct |
159 ms |
142148 KB |
Output is correct |
50 |
Correct |
163 ms |
152104 KB |
Output is correct |
51 |
Correct |
94 ms |
74320 KB |
Output is correct |
52 |
Correct |
1 ms |
332 KB |
Output is correct |
53 |
Correct |
94 ms |
87876 KB |
Output is correct |
54 |
Correct |
101 ms |
78092 KB |
Output is correct |
55 |
Correct |
94 ms |
84544 KB |
Output is correct |
56 |
Correct |
106 ms |
78020 KB |
Output is correct |
57 |
Correct |
102 ms |
85572 KB |
Output is correct |
58 |
Correct |
97 ms |
85112 KB |
Output is correct |
59 |
Correct |
89 ms |
76108 KB |
Output is correct |
60 |
Correct |
93 ms |
77160 KB |
Output is correct |
61 |
Correct |
87 ms |
79328 KB |
Output is correct |
62 |
Correct |
159 ms |
141208 KB |
Output is correct |
63 |
Correct |
167 ms |
140344 KB |
Output is correct |
64 |
Correct |
166 ms |
147876 KB |
Output is correct |
65 |
Correct |
138 ms |
143592 KB |
Output is correct |
66 |
Correct |
151 ms |
145600 KB |
Output is correct |
67 |
Correct |
156 ms |
146912 KB |
Output is correct |
68 |
Correct |
146 ms |
143436 KB |
Output is correct |
69 |
Correct |
165 ms |
142232 KB |
Output is correct |
70 |
Correct |
191 ms |
152108 KB |
Output is correct |
71 |
Correct |
85 ms |
74240 KB |
Output is correct |
72 |
Correct |
1 ms |
204 KB |
Output is correct |
73 |
Correct |
113 ms |
87968 KB |
Output is correct |
74 |
Correct |
104 ms |
78088 KB |
Output is correct |
75 |
Correct |
110 ms |
84452 KB |
Output is correct |
76 |
Correct |
93 ms |
78024 KB |
Output is correct |
77 |
Correct |
97 ms |
85484 KB |
Output is correct |
78 |
Correct |
96 ms |
85052 KB |
Output is correct |
79 |
Correct |
102 ms |
76104 KB |
Output is correct |
80 |
Correct |
102 ms |
77148 KB |
Output is correct |
81 |
Correct |
95 ms |
79332 KB |
Output is correct |
82 |
Correct |
153 ms |
141284 KB |
Output is correct |
83 |
Correct |
162 ms |
140424 KB |
Output is correct |
84 |
Correct |
177 ms |
147800 KB |
Output is correct |
85 |
Correct |
166 ms |
143664 KB |
Output is correct |
86 |
Correct |
171 ms |
145588 KB |
Output is correct |
87 |
Correct |
155 ms |
146812 KB |
Output is correct |
88 |
Correct |
225 ms |
143420 KB |
Output is correct |
89 |
Correct |
152 ms |
142156 KB |
Output is correct |
90 |
Correct |
161 ms |
152004 KB |
Output is correct |
91 |
Correct |
91 ms |
74316 KB |
Output is correct |
92 |
Correct |
1 ms |
204 KB |
Output is correct |
93 |
Correct |
97 ms |
87856 KB |
Output is correct |
94 |
Correct |
93 ms |
78088 KB |
Output is correct |
95 |
Correct |
88 ms |
84548 KB |
Output is correct |
96 |
Correct |
89 ms |
78016 KB |
Output is correct |
97 |
Correct |
109 ms |
85580 KB |
Output is correct |
98 |
Correct |
101 ms |
85068 KB |
Output is correct |
99 |
Correct |
94 ms |
76012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
284 KB |
1st lines differ - on the 1st token, expected: '5', found: '4' |
9 |
Halted |
0 ms |
0 KB |
- |