#include "jelly.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include "bits/stdc++.h"
using namespace std;
const int N = 2005;
int dp[N][(int)1e4+5];
int rdp[N][(int)1e4+5];
#define ff first
#define ss second
template<class T> bool umin(T& a, const T b) { if(a > b) { a = b; return 1; } return 0; }
template<class T> bool umax(T& a, const T b) { if(a < b) { a = b; return 1; } return 0; }
const int mod = 1e9+7;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = (int)a.size();
vector<pair<int, int>> tt;
for(int i=0;i<n;i++) tt.push_back({a[i], b[i]});
tt.push_back({-1, -1});
sort(tt.begin(), tt.end());
memset(dp, 127, sizeof dp);
memset(dp[0], 0, sizeof dp[0]);
for(int i=1;i<=n;i++){
for(int j=0;j<=x;j++){
if(~dp[i-1][j]) umin(dp[i][j], dp[i-1][j] + tt[i].ss);
if(j >= tt[i].ff && ~dp[i-1][j-tt[i].ff]) umin(dp[i][j], dp[i-1][j - tt[i].ff]);
}
}
for(int i=n;i>0;i--){
for(int j=0;j<y;j++){
if(j) umax(rdp[i][j], rdp[i][j-1]);
if(j >= tt[i].ss) umax(rdp[i][j], rdp[i+1][j-tt[i].ss] + 1);
}
}
int res = 0;
for(int i=1;i<=n;i++){
for(int j=0;j<=x;j++){
if(dp[i][j] <= y) umax(res, i + rdp[i+1][y - dp[i][j]] );
}
}
return res;
}
/*
5 6 12
5 1 5 6 3
3 5 4 6 7
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
78788 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
78788 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
78816 KB |
1st lines differ - on the 1st token, expected: '689', found: '65' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
102 ms |
91876 KB |
Output is correct |
2 |
Correct |
158 ms |
120872 KB |
Output is correct |
3 |
Correct |
177 ms |
119316 KB |
Output is correct |
4 |
Correct |
212 ms |
153456 KB |
Output is correct |
5 |
Correct |
210 ms |
156300 KB |
Output is correct |
6 |
Correct |
173 ms |
138004 KB |
Output is correct |
7 |
Correct |
163 ms |
126920 KB |
Output is correct |
8 |
Correct |
142 ms |
100804 KB |
Output is correct |
9 |
Correct |
202 ms |
153632 KB |
Output is correct |
10 |
Correct |
206 ms |
154820 KB |
Output is correct |
11 |
Correct |
105 ms |
116824 KB |
Output is correct |
12 |
Correct |
39 ms |
78740 KB |
Output is correct |
13 |
Correct |
117 ms |
132416 KB |
Output is correct |
14 |
Correct |
140 ms |
154816 KB |
Output is correct |
15 |
Correct |
163 ms |
155076 KB |
Output is correct |
16 |
Correct |
107 ms |
121868 KB |
Output is correct |
17 |
Correct |
97 ms |
87292 KB |
Output is correct |
18 |
Correct |
109 ms |
92484 KB |
Output is correct |
19 |
Correct |
123 ms |
92996 KB |
Output is correct |
20 |
Correct |
110 ms |
87836 KB |
Output is correct |
21 |
Correct |
116 ms |
91924 KB |
Output is correct |
22 |
Correct |
163 ms |
120900 KB |
Output is correct |
23 |
Correct |
163 ms |
119344 KB |
Output is correct |
24 |
Correct |
211 ms |
153412 KB |
Output is correct |
25 |
Correct |
211 ms |
156280 KB |
Output is correct |
26 |
Correct |
171 ms |
138112 KB |
Output is correct |
27 |
Correct |
163 ms |
126868 KB |
Output is correct |
28 |
Correct |
144 ms |
100884 KB |
Output is correct |
29 |
Correct |
203 ms |
153620 KB |
Output is correct |
30 |
Correct |
215 ms |
154872 KB |
Output is correct |
31 |
Correct |
108 ms |
116844 KB |
Output is correct |
32 |
Correct |
38 ms |
78788 KB |
Output is correct |
33 |
Correct |
135 ms |
132416 KB |
Output is correct |
34 |
Correct |
145 ms |
154708 KB |
Output is correct |
35 |
Correct |
154 ms |
155180 KB |
Output is correct |
36 |
Correct |
108 ms |
121776 KB |
Output is correct |
37 |
Correct |
116 ms |
87240 KB |
Output is correct |
38 |
Correct |
113 ms |
92440 KB |
Output is correct |
39 |
Correct |
125 ms |
93092 KB |
Output is correct |
40 |
Correct |
109 ms |
87820 KB |
Output is correct |
41 |
Correct |
108 ms |
91892 KB |
Output is correct |
42 |
Correct |
171 ms |
120896 KB |
Output is correct |
43 |
Correct |
161 ms |
119388 KB |
Output is correct |
44 |
Correct |
215 ms |
153520 KB |
Output is correct |
45 |
Correct |
218 ms |
156228 KB |
Output is correct |
46 |
Correct |
175 ms |
137936 KB |
Output is correct |
47 |
Correct |
174 ms |
126968 KB |
Output is correct |
48 |
Correct |
152 ms |
100904 KB |
Output is correct |
49 |
Correct |
214 ms |
153672 KB |
Output is correct |
50 |
Correct |
228 ms |
154704 KB |
Output is correct |
51 |
Correct |
109 ms |
116844 KB |
Output is correct |
52 |
Correct |
36 ms |
78844 KB |
Output is correct |
53 |
Correct |
117 ms |
132432 KB |
Output is correct |
54 |
Correct |
142 ms |
154760 KB |
Output is correct |
55 |
Correct |
156 ms |
155152 KB |
Output is correct |
56 |
Correct |
107 ms |
121780 KB |
Output is correct |
57 |
Correct |
95 ms |
87340 KB |
Output is correct |
58 |
Correct |
103 ms |
92484 KB |
Output is correct |
59 |
Correct |
121 ms |
93128 KB |
Output is correct |
60 |
Correct |
109 ms |
87916 KB |
Output is correct |
61 |
Correct |
109 ms |
91900 KB |
Output is correct |
62 |
Correct |
160 ms |
120888 KB |
Output is correct |
63 |
Correct |
163 ms |
119436 KB |
Output is correct |
64 |
Correct |
211 ms |
153584 KB |
Output is correct |
65 |
Correct |
202 ms |
156184 KB |
Output is correct |
66 |
Correct |
171 ms |
137996 KB |
Output is correct |
67 |
Correct |
165 ms |
126920 KB |
Output is correct |
68 |
Correct |
140 ms |
100836 KB |
Output is correct |
69 |
Correct |
224 ms |
153736 KB |
Output is correct |
70 |
Correct |
217 ms |
154764 KB |
Output is correct |
71 |
Correct |
103 ms |
116804 KB |
Output is correct |
72 |
Correct |
42 ms |
78796 KB |
Output is correct |
73 |
Correct |
121 ms |
132408 KB |
Output is correct |
74 |
Correct |
135 ms |
154820 KB |
Output is correct |
75 |
Correct |
149 ms |
155120 KB |
Output is correct |
76 |
Correct |
111 ms |
121856 KB |
Output is correct |
77 |
Correct |
104 ms |
87236 KB |
Output is correct |
78 |
Correct |
107 ms |
92540 KB |
Output is correct |
79 |
Correct |
120 ms |
92984 KB |
Output is correct |
80 |
Correct |
112 ms |
87924 KB |
Output is correct |
81 |
Correct |
137 ms |
91952 KB |
Output is correct |
82 |
Correct |
180 ms |
120820 KB |
Output is correct |
83 |
Correct |
211 ms |
119372 KB |
Output is correct |
84 |
Correct |
239 ms |
153540 KB |
Output is correct |
85 |
Correct |
208 ms |
156264 KB |
Output is correct |
86 |
Correct |
178 ms |
137992 KB |
Output is correct |
87 |
Correct |
190 ms |
126872 KB |
Output is correct |
88 |
Correct |
141 ms |
100840 KB |
Output is correct |
89 |
Correct |
198 ms |
153664 KB |
Output is correct |
90 |
Correct |
228 ms |
154788 KB |
Output is correct |
91 |
Correct |
108 ms |
116900 KB |
Output is correct |
92 |
Correct |
36 ms |
78792 KB |
Output is correct |
93 |
Correct |
126 ms |
132432 KB |
Output is correct |
94 |
Correct |
145 ms |
154780 KB |
Output is correct |
95 |
Correct |
150 ms |
155176 KB |
Output is correct |
96 |
Correct |
107 ms |
121804 KB |
Output is correct |
97 |
Correct |
104 ms |
87292 KB |
Output is correct |
98 |
Correct |
138 ms |
92432 KB |
Output is correct |
99 |
Correct |
142 ms |
92920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
103 ms |
85720 KB |
Output is correct |
2 |
Correct |
154 ms |
119936 KB |
Output is correct |
3 |
Correct |
159 ms |
120848 KB |
Output is correct |
4 |
Correct |
231 ms |
155460 KB |
Output is correct |
5 |
Correct |
212 ms |
153284 KB |
Output is correct |
6 |
Correct |
201 ms |
124180 KB |
Output is correct |
7 |
Correct |
184 ms |
124456 KB |
Output is correct |
8 |
Correct |
192 ms |
122004 KB |
Output is correct |
9 |
Correct |
200 ms |
155804 KB |
Output is correct |
10 |
Correct |
211 ms |
156896 KB |
Output is correct |
11 |
Correct |
140 ms |
153456 KB |
Output is correct |
12 |
Correct |
36 ms |
78788 KB |
Output is correct |
13 |
Correct |
141 ms |
149292 KB |
Output is correct |
14 |
Correct |
156 ms |
155932 KB |
Output is correct |
15 |
Correct |
149 ms |
154052 KB |
Output is correct |
16 |
Correct |
131 ms |
146828 KB |
Output is correct |
17 |
Correct |
124 ms |
88132 KB |
Output is correct |
18 |
Correct |
106 ms |
88052 KB |
Output is correct |
19 |
Correct |
114 ms |
87432 KB |
Output is correct |
20 |
Correct |
117 ms |
87240 KB |
Output is correct |
21 |
Correct |
101 ms |
85648 KB |
Output is correct |
22 |
Correct |
176 ms |
119964 KB |
Output is correct |
23 |
Correct |
170 ms |
120868 KB |
Output is correct |
24 |
Correct |
209 ms |
155444 KB |
Output is correct |
25 |
Correct |
248 ms |
153228 KB |
Output is correct |
26 |
Correct |
160 ms |
124276 KB |
Output is correct |
27 |
Correct |
231 ms |
124352 KB |
Output is correct |
28 |
Correct |
156 ms |
121960 KB |
Output is correct |
29 |
Correct |
200 ms |
155716 KB |
Output is correct |
30 |
Correct |
210 ms |
156792 KB |
Output is correct |
31 |
Correct |
185 ms |
153484 KB |
Output is correct |
32 |
Correct |
38 ms |
78740 KB |
Output is correct |
33 |
Correct |
144 ms |
149248 KB |
Output is correct |
34 |
Correct |
140 ms |
155972 KB |
Output is correct |
35 |
Correct |
205 ms |
154116 KB |
Output is correct |
36 |
Correct |
134 ms |
146764 KB |
Output is correct |
37 |
Correct |
108 ms |
88200 KB |
Output is correct |
38 |
Correct |
148 ms |
88080 KB |
Output is correct |
39 |
Correct |
112 ms |
87412 KB |
Output is correct |
40 |
Correct |
123 ms |
87180 KB |
Output is correct |
41 |
Correct |
105 ms |
85712 KB |
Output is correct |
42 |
Correct |
157 ms |
119968 KB |
Output is correct |
43 |
Correct |
154 ms |
120748 KB |
Output is correct |
44 |
Correct |
217 ms |
155332 KB |
Output is correct |
45 |
Correct |
204 ms |
153272 KB |
Output is correct |
46 |
Correct |
156 ms |
124228 KB |
Output is correct |
47 |
Correct |
160 ms |
124316 KB |
Output is correct |
48 |
Correct |
156 ms |
122048 KB |
Output is correct |
49 |
Correct |
202 ms |
155808 KB |
Output is correct |
50 |
Correct |
209 ms |
156868 KB |
Output is correct |
51 |
Correct |
138 ms |
153540 KB |
Output is correct |
52 |
Correct |
39 ms |
78788 KB |
Output is correct |
53 |
Correct |
144 ms |
149352 KB |
Output is correct |
54 |
Correct |
143 ms |
155932 KB |
Output is correct |
55 |
Correct |
150 ms |
154052 KB |
Output is correct |
56 |
Correct |
136 ms |
146744 KB |
Output is correct |
57 |
Correct |
109 ms |
88056 KB |
Output is correct |
58 |
Correct |
108 ms |
88012 KB |
Output is correct |
59 |
Correct |
117 ms |
87436 KB |
Output is correct |
60 |
Correct |
113 ms |
87280 KB |
Output is correct |
61 |
Correct |
105 ms |
85652 KB |
Output is correct |
62 |
Correct |
159 ms |
119848 KB |
Output is correct |
63 |
Correct |
155 ms |
120780 KB |
Output is correct |
64 |
Correct |
207 ms |
155368 KB |
Output is correct |
65 |
Correct |
207 ms |
153356 KB |
Output is correct |
66 |
Correct |
157 ms |
124160 KB |
Output is correct |
67 |
Correct |
164 ms |
124372 KB |
Output is correct |
68 |
Correct |
161 ms |
121904 KB |
Output is correct |
69 |
Correct |
207 ms |
156012 KB |
Output is correct |
70 |
Correct |
211 ms |
156788 KB |
Output is correct |
71 |
Correct |
138 ms |
153480 KB |
Output is correct |
72 |
Correct |
38 ms |
78836 KB |
Output is correct |
73 |
Correct |
145 ms |
149412 KB |
Output is correct |
74 |
Correct |
145 ms |
155852 KB |
Output is correct |
75 |
Correct |
149 ms |
154124 KB |
Output is correct |
76 |
Correct |
136 ms |
146804 KB |
Output is correct |
77 |
Correct |
110 ms |
88268 KB |
Output is correct |
78 |
Correct |
107 ms |
88092 KB |
Output is correct |
79 |
Correct |
123 ms |
87396 KB |
Output is correct |
80 |
Correct |
121 ms |
87256 KB |
Output is correct |
81 |
Correct |
110 ms |
85776 KB |
Output is correct |
82 |
Correct |
178 ms |
120060 KB |
Output is correct |
83 |
Correct |
153 ms |
120852 KB |
Output is correct |
84 |
Correct |
206 ms |
155332 KB |
Output is correct |
85 |
Correct |
206 ms |
153196 KB |
Output is correct |
86 |
Correct |
165 ms |
124256 KB |
Output is correct |
87 |
Correct |
164 ms |
124320 KB |
Output is correct |
88 |
Correct |
158 ms |
121924 KB |
Output is correct |
89 |
Correct |
201 ms |
155764 KB |
Output is correct |
90 |
Correct |
210 ms |
156912 KB |
Output is correct |
91 |
Correct |
136 ms |
153528 KB |
Output is correct |
92 |
Correct |
37 ms |
78816 KB |
Output is correct |
93 |
Correct |
146 ms |
149460 KB |
Output is correct |
94 |
Correct |
142 ms |
156068 KB |
Output is correct |
95 |
Correct |
147 ms |
154052 KB |
Output is correct |
96 |
Correct |
135 ms |
146760 KB |
Output is correct |
97 |
Correct |
104 ms |
88132 KB |
Output is correct |
98 |
Correct |
127 ms |
88100 KB |
Output is correct |
99 |
Correct |
113 ms |
87384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
78788 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |