#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6+1;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){
int n = a.size();
vector<int> order(n);
iota(order.begin(),order.end(),0);
sort(order.begin(),order.end(),[&](int c, int d){
if(a[c] == a[d])
return b[c] > b[d];
return a[c] < a[d];});
vector<multiset<int>> v(n+1);
for(int i = n-1; i >= 0; i--){
v[i] = v[i+1];
v[i].insert(b[order[i]]);
}
int resp = 0;
int cury = y;
for(int i : v[0]){
if(i <= cury)
cury-=i, resp++;
else break;
}
vector<int> dp(x+1,0);
for(int i = 0; i < n; i++){
//cerr << i << endl;
for(int j = x; j >= 0; j--){
dp[j] = min(dp[j] + b[i], i >= a[i] ? dp[j-a[i]] : INF);
}
if(dp[x] > y)
continue;
int curresp = i+1;
cury = y-dp[x];
for(int j : v[i+1]){
if(j > cury)
break;
curresp++;
cury-=j;
}
resp = max(resp,curresp);
}
return resp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
1st lines differ - on the 1st token, expected: '8', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
1st lines differ - on the 1st token, expected: '8', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
89584 KB |
1st lines differ - on the 1st token, expected: '689', found: '1949' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
184 ms |
88492 KB |
1st lines differ - on the 1st token, expected: '62', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
90592 KB |
1st lines differ - on the 1st token, expected: '154', found: '1959' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
1st lines differ - on the 1st token, expected: '8', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |