이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
#define X first
#define Y second
#define sep ' '
#define all(x) (x).begin() , (x).end()
#define SZ(x) int(x.size())
vector<int> find_subset(int l, int u, vector<int> w) {
vector<pii> vec;
vector<int> ans1 , ans2;
int n = SZ(w) ; ll sum = 0;
for(int i = 0 ; i < n ; i++){
vec.push_back({w[i] , i});
}
sort(all(vec));
for(pii i : vec){
sum += i.X;
ans1.push_back(i.Y);
if(sum >= l) break;
}
if(sum <= u){
sort(all(ans1));
return ans1;
}
sum -= w[ans1.back()]; ans1.pop_back();
while(SZ(ans1)){
sum -= w[ans1.back()]; ans1.pop_back(); n--;
sum += w[vec[n].Y]; ans2.push_back(vec[n].Y);
if(l <= sum){
for(int i : ans2) ans1.push_back(i);
sort(all(ans1));
return ans1;
}
}
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... |