이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
ll s = 0, L = l, R = u;
int n = w.size();
vector < int > ans;
vector < pair < int, int > > a;
for(int i = 0; i < n; i++) a.push_back({w[i], i});
sort(a.begin(), a.end());
for(int i = 0; i < n; i++){
s += a[i].first;
if(L <= s && s <= R){
for(int j = 0; j <= i; j++) ans.push_back(a[j].second);
// for(int it : ans) cout << it << ' ';
// cout << '\n';
return ans;
}
}
s = 0;
reverse(a.begin(), a.end());
for(int i = 0; i < n; i++){
s += a[i].first;
if(L <= s && s <= R){
for(int j = 0; j <= i; j++) ans.push_back(a[j].second);
// for(int it : ans) cout << it << ' ';
// cout << '\n';
return ans;
}
}
int it = 10000;
while(it--){
s = 0;
random_shuffle(a.begin(), a.end());
// for(auto it : a) cout << it.first << ' ';
// cout << '\n';
for(int i = 0; i < n; i++){
s += a[i].first;
if(L <= s && s <= R){
for(int j = 0; j <= i; j++) ans.push_back(a[j].second);
// for(int it : ans) cout << it << ' ';
// cout << '\n';
return ans;
}
}
}
return ans;
}
# | 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... |