#include<bits/stdc++.h>
using namespace std;
typedef array<int, 2> pii;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){
int n = a.size();
vector<pii> c(n);
for(int i = 0; i < n; ++i) c[i] = {a[i], b[i]};
sort(c.begin(), c.end());
vector<vector<int>> v(n+1, vector<int>(x+1)), w(n+1, vector<int>(y+1));
// v: buy i cheapest jelly, given money spent in a, find min extra cost in b
for(int i = 1; i <= n; ++i){
for(int j = 0; j <= x; ++j){
v[i][j] = v[i-1][j] + c[i-1][1];
if(j >= c[i-1][0]) v[i][j] = min(v[i][j], v[i-1][j-c[i-1][0]]);
}
}
// w: buy in b jelly that would be expensive in a, find max jelly
for(int i = n-1; i >= 0; --i){
for(int j = 0; j <= y; ++j){
w[i][j] = w[i+1][j];
if(j >= c[i][1]) v[i][j] = max(v[i][j], v[i+1][j-c[i][1]]+1);
}
}
int ans = 0;
for(int i = 0; i <= n; ++i){
int yy = y - v[i][x];
if(yy >= 0) ans = max(ans, i + w[i][yy]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
13548 KB |
1st lines differ - on the 1st token, expected: '689', found: '65' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
81792 KB |
Output is correct |
2 |
Runtime error |
238 ms |
146796 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
79724 KB |
Output is correct |
2 |
Correct |
142 ms |
141548 KB |
Output is correct |
3 |
Correct |
144 ms |
140524 KB |
Output is correct |
4 |
Correct |
179 ms |
148204 KB |
Output is correct |
5 |
Runtime error |
287 ms |
144580 KB |
Execution killed with signal 6 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
1st lines differ - on the 1st token, expected: '8', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |