#include "jelly.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
const int MAXM = 1e4 + 10;
int dp[MAXN][MAXM];
int calc(int i, int x, int y, int N, vector<int> &a, vector<int> &b)
{
if(x < 0 || y < 0) return -1;
if(dp[i][y] != 0) return dp[i][y];
if(i > N) return 0;
int op1 = calc(i + 1, x - a[i - 1], y, N, a, b) + 1;
int op2 = calc(i + 1, x, y - b[i - 1], N , a, b) + 1;
dp[i][y] = max(op1,op2);
return dp[i][y];
}
bool cmp(pair<int,int> a, pair<int,int> b)
{
if(a.first == b.first) return a.second < b.second;
return a.first < b.first;
}
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
int N = a.size();
vector<pair<int,int>> aux;
for(int i = 0; i < N; i++)
aux.push_back({a[i],b[i]});
sort(aux.begin(),aux.end(),cmp);
for(int i = 0; i < N; i++)
{
a[i] = aux[i].first;
b[i] = aux[i].second;
}
return calc(1,x,y,N,a,b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
1st lines differ - on the 1st token, expected: '689', found: '59' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
856 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
45 ms |
34216 KB |
Output is correct |
5 |
Correct |
51 ms |
54048 KB |
Output is correct |
6 |
Correct |
2 ms |
1724 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
45 ms |
50660 KB |
Output is correct |
10 |
Correct |
38 ms |
22100 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
12 ms |
9820 KB |
Output is correct |
15 |
Correct |
15 ms |
23644 KB |
Output is correct |
16 |
Correct |
1 ms |
824 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
1116 KB |
Output is correct |
19 |
Correct |
9 ms |
11356 KB |
Output is correct |
20 |
Correct |
5 ms |
7512 KB |
Output is correct |
21 |
Correct |
1 ms |
860 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
48 ms |
34168 KB |
Output is correct |
25 |
Correct |
52 ms |
53820 KB |
Output is correct |
26 |
Correct |
1 ms |
1368 KB |
Output is correct |
27 |
Correct |
1 ms |
1112 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
45 ms |
50772 KB |
Output is correct |
30 |
Correct |
37 ms |
22096 KB |
Output is correct |
31 |
Correct |
1 ms |
856 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
1116 KB |
Output is correct |
34 |
Correct |
11 ms |
9760 KB |
Output is correct |
35 |
Correct |
16 ms |
23644 KB |
Output is correct |
36 |
Correct |
1 ms |
860 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
1 ms |
1116 KB |
Output is correct |
39 |
Correct |
9 ms |
11308 KB |
Output is correct |
40 |
Correct |
5 ms |
7516 KB |
Output is correct |
41 |
Correct |
1 ms |
860 KB |
Output is correct |
42 |
Correct |
1 ms |
860 KB |
Output is correct |
43 |
Correct |
1 ms |
860 KB |
Output is correct |
44 |
Correct |
45 ms |
34256 KB |
Output is correct |
45 |
Correct |
56 ms |
53844 KB |
Output is correct |
46 |
Correct |
1 ms |
1372 KB |
Output is correct |
47 |
Correct |
1 ms |
1116 KB |
Output is correct |
48 |
Correct |
1 ms |
856 KB |
Output is correct |
49 |
Correct |
42 ms |
50836 KB |
Output is correct |
50 |
Correct |
35 ms |
22108 KB |
Output is correct |
51 |
Correct |
1 ms |
860 KB |
Output is correct |
52 |
Correct |
1 ms |
348 KB |
Output is correct |
53 |
Correct |
1 ms |
1116 KB |
Output is correct |
54 |
Correct |
12 ms |
9716 KB |
Output is correct |
55 |
Correct |
15 ms |
23528 KB |
Output is correct |
56 |
Correct |
1 ms |
860 KB |
Output is correct |
57 |
Correct |
1 ms |
856 KB |
Output is correct |
58 |
Correct |
1 ms |
1116 KB |
Output is correct |
59 |
Correct |
9 ms |
11356 KB |
Output is correct |
60 |
Correct |
5 ms |
7516 KB |
Output is correct |
61 |
Correct |
1 ms |
928 KB |
Output is correct |
62 |
Correct |
1 ms |
860 KB |
Output is correct |
63 |
Correct |
1 ms |
860 KB |
Output is correct |
64 |
Correct |
51 ms |
34132 KB |
Output is correct |
65 |
Correct |
58 ms |
53844 KB |
Output is correct |
66 |
Correct |
1 ms |
1368 KB |
Output is correct |
67 |
Correct |
1 ms |
1116 KB |
Output is correct |
68 |
Correct |
1 ms |
860 KB |
Output is correct |
69 |
Correct |
45 ms |
50736 KB |
Output is correct |
70 |
Correct |
37 ms |
22108 KB |
Output is correct |
71 |
Correct |
1 ms |
860 KB |
Output is correct |
72 |
Correct |
1 ms |
348 KB |
Output is correct |
73 |
Correct |
1 ms |
1116 KB |
Output is correct |
74 |
Correct |
11 ms |
9820 KB |
Output is correct |
75 |
Correct |
16 ms |
23640 KB |
Output is correct |
76 |
Correct |
1 ms |
860 KB |
Output is correct |
77 |
Correct |
1 ms |
604 KB |
Output is correct |
78 |
Correct |
1 ms |
1116 KB |
Output is correct |
79 |
Correct |
9 ms |
11480 KB |
Output is correct |
80 |
Correct |
5 ms |
7516 KB |
Output is correct |
81 |
Correct |
1 ms |
860 KB |
Output is correct |
82 |
Correct |
1 ms |
860 KB |
Output is correct |
83 |
Correct |
1 ms |
860 KB |
Output is correct |
84 |
Correct |
46 ms |
34132 KB |
Output is correct |
85 |
Correct |
65 ms |
54148 KB |
Output is correct |
86 |
Correct |
1 ms |
1372 KB |
Output is correct |
87 |
Correct |
1 ms |
984 KB |
Output is correct |
88 |
Correct |
1 ms |
860 KB |
Output is correct |
89 |
Correct |
41 ms |
50772 KB |
Output is correct |
90 |
Correct |
35 ms |
22108 KB |
Output is correct |
91 |
Correct |
1 ms |
856 KB |
Output is correct |
92 |
Correct |
1 ms |
348 KB |
Output is correct |
93 |
Correct |
1 ms |
1116 KB |
Output is correct |
94 |
Correct |
11 ms |
9820 KB |
Output is correct |
95 |
Correct |
15 ms |
23640 KB |
Output is correct |
96 |
Correct |
1 ms |
856 KB |
Output is correct |
97 |
Correct |
1 ms |
604 KB |
Output is correct |
98 |
Correct |
1 ms |
1116 KB |
Output is correct |
99 |
Correct |
9 ms |
11356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1624 KB |
Output is correct |
2 |
Correct |
5 ms |
2140 KB |
Output is correct |
3 |
Correct |
5 ms |
1884 KB |
Output is correct |
4 |
Correct |
94 ms |
38616 KB |
Output is correct |
5 |
Correct |
96 ms |
36276 KB |
Output is correct |
6 |
Correct |
5 ms |
2140 KB |
Output is correct |
7 |
Correct |
5 ms |
1884 KB |
Output is correct |
8 |
Correct |
5 ms |
2128 KB |
Output is correct |
9 |
Correct |
90 ms |
37972 KB |
Output is correct |
10 |
Correct |
92 ms |
40236 KB |
Output is correct |
11 |
Correct |
3 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
1372 KB |
Output is correct |
14 |
Correct |
21 ms |
11612 KB |
Output is correct |
15 |
Correct |
44 ms |
18340 KB |
Output is correct |
16 |
Correct |
2 ms |
1372 KB |
Output is correct |
17 |
Correct |
3 ms |
1372 KB |
Output is correct |
18 |
Correct |
3 ms |
1372 KB |
Output is correct |
19 |
Correct |
6 ms |
8792 KB |
Output is correct |
20 |
Correct |
5 ms |
8792 KB |
Output is correct |
21 |
Correct |
2 ms |
1628 KB |
Output is correct |
22 |
Correct |
5 ms |
2256 KB |
Output is correct |
23 |
Correct |
5 ms |
1884 KB |
Output is correct |
24 |
Correct |
91 ms |
38696 KB |
Output is correct |
25 |
Correct |
82 ms |
36432 KB |
Output is correct |
26 |
Correct |
5 ms |
2140 KB |
Output is correct |
27 |
Correct |
5 ms |
2140 KB |
Output is correct |
28 |
Correct |
5 ms |
2140 KB |
Output is correct |
29 |
Correct |
98 ms |
38008 KB |
Output is correct |
30 |
Correct |
93 ms |
40272 KB |
Output is correct |
31 |
Correct |
2 ms |
1624 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
3 ms |
1372 KB |
Output is correct |
34 |
Correct |
18 ms |
11340 KB |
Output is correct |
35 |
Correct |
41 ms |
18512 KB |
Output is correct |
36 |
Correct |
2 ms |
1372 KB |
Output is correct |
37 |
Correct |
3 ms |
1556 KB |
Output is correct |
38 |
Correct |
3 ms |
1372 KB |
Output is correct |
39 |
Correct |
6 ms |
8796 KB |
Output is correct |
40 |
Correct |
5 ms |
8796 KB |
Output is correct |
41 |
Correct |
2 ms |
1628 KB |
Output is correct |
42 |
Correct |
5 ms |
2136 KB |
Output is correct |
43 |
Correct |
5 ms |
1884 KB |
Output is correct |
44 |
Correct |
95 ms |
38780 KB |
Output is correct |
45 |
Correct |
87 ms |
36456 KB |
Output is correct |
46 |
Correct |
5 ms |
2140 KB |
Output is correct |
47 |
Correct |
5 ms |
1884 KB |
Output is correct |
48 |
Correct |
5 ms |
2140 KB |
Output is correct |
49 |
Correct |
90 ms |
38144 KB |
Output is correct |
50 |
Correct |
99 ms |
40276 KB |
Output is correct |
51 |
Correct |
2 ms |
1628 KB |
Output is correct |
52 |
Correct |
1 ms |
348 KB |
Output is correct |
53 |
Correct |
3 ms |
1372 KB |
Output is correct |
54 |
Correct |
18 ms |
11356 KB |
Output is correct |
55 |
Correct |
38 ms |
18344 KB |
Output is correct |
56 |
Correct |
2 ms |
1368 KB |
Output is correct |
57 |
Correct |
3 ms |
1372 KB |
Output is correct |
58 |
Correct |
3 ms |
1372 KB |
Output is correct |
59 |
Correct |
6 ms |
8908 KB |
Output is correct |
60 |
Correct |
5 ms |
8792 KB |
Output is correct |
61 |
Correct |
2 ms |
1628 KB |
Output is correct |
62 |
Correct |
5 ms |
2140 KB |
Output is correct |
63 |
Correct |
4 ms |
1884 KB |
Output is correct |
64 |
Correct |
87 ms |
38812 KB |
Output is correct |
65 |
Correct |
81 ms |
36432 KB |
Output is correct |
66 |
Correct |
5 ms |
2140 KB |
Output is correct |
67 |
Correct |
7 ms |
1884 KB |
Output is correct |
68 |
Correct |
5 ms |
2136 KB |
Output is correct |
69 |
Correct |
88 ms |
37960 KB |
Output is correct |
70 |
Correct |
92 ms |
40276 KB |
Output is correct |
71 |
Correct |
2 ms |
1628 KB |
Output is correct |
72 |
Correct |
1 ms |
348 KB |
Output is correct |
73 |
Correct |
3 ms |
1372 KB |
Output is correct |
74 |
Correct |
19 ms |
11356 KB |
Output is correct |
75 |
Correct |
46 ms |
18544 KB |
Output is correct |
76 |
Correct |
2 ms |
1368 KB |
Output is correct |
77 |
Correct |
3 ms |
1372 KB |
Output is correct |
78 |
Correct |
3 ms |
1372 KB |
Output is correct |
79 |
Correct |
6 ms |
8796 KB |
Output is correct |
80 |
Correct |
5 ms |
8796 KB |
Output is correct |
81 |
Correct |
2 ms |
1628 KB |
Output is correct |
82 |
Correct |
5 ms |
2140 KB |
Output is correct |
83 |
Correct |
5 ms |
1884 KB |
Output is correct |
84 |
Correct |
88 ms |
38704 KB |
Output is correct |
85 |
Correct |
83 ms |
36496 KB |
Output is correct |
86 |
Correct |
5 ms |
2136 KB |
Output is correct |
87 |
Correct |
5 ms |
1884 KB |
Output is correct |
88 |
Correct |
5 ms |
2132 KB |
Output is correct |
89 |
Correct |
89 ms |
37972 KB |
Output is correct |
90 |
Correct |
93 ms |
40268 KB |
Output is correct |
91 |
Correct |
2 ms |
1624 KB |
Output is correct |
92 |
Correct |
1 ms |
348 KB |
Output is correct |
93 |
Correct |
2 ms |
1372 KB |
Output is correct |
94 |
Correct |
18 ms |
11356 KB |
Output is correct |
95 |
Correct |
45 ms |
18332 KB |
Output is correct |
96 |
Correct |
2 ms |
1368 KB |
Output is correct |
97 |
Correct |
3 ms |
1368 KB |
Output is correct |
98 |
Correct |
2 ms |
1372 KB |
Output is correct |
99 |
Correct |
6 ms |
8792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |