이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define pb push_back
#define pi pair<int,int>
#define w first
#define ind second
#define ll long long
#define mp make_pair
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
//set<pi> weights;
vector<pi> weights(n);
for(int i =0; i<n ;i++){
//weights.insert({w[i], i});
weights[i] = {w[i], i};
}
sort(weights.begin(), weights.end());
vector<int> ans;
ll cursum = 0;
for(int i = n-1; i>= 0; i--){
if( cursum + weights[i].w > u) continue;
cursum += weights[i].w;
ans.pb(weights[i].ind);
if( l <= cursum && u >= cursum){
sort(ans.begin(), ans.end());
return ans;
}
}
/*auto it = weights.begin();
while(true){
it = lower_bound(weights.begin(), weights.end(), mp(u - cursum + 1, - 1) );
if(it == weights.begin())
break;
it = prev(it);
cout << it ->w<<endl;
cursum += it->w;
ans.pb(it->ind);
it = weights.erase(it);
if( l<= cursum and cursum <=u){
sort(ans.begin(), ans.end());
//for(int a : ans)cout << a <<",";
//cout <<endl;
return ans;
}
if(it == weights.begin()){
break;
}
it = prev(it);
}
*/
return vector<int>();
}
/***************/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |