이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define ff first
#define ss second
vector<int> find_subset(int l, int u, vector<int> w){
vector<pair<int, int> > w_sort;
int n = w.size();
for(int i = 0; i < n; i++) w_sort.push_back({w[i], i});
sort(w_sort.begin(), w_sort.end());
int sum = 0;
vector<int> ans;
for(int i = 0; i < n; i++){
sum += w_sort[i].ff;
ans.push_back(w_sort[i].ss);
if(l <= sum && sum <= u) return ans;
}
ans.clear();
if(sum > l || w_sort[0].ff > u) return ans;
int last = 0; sum = 0;
for(int i = 0; i < n; i++) {
if(sum + w_sort[i].ff > l) break;
sum += w_sort[i].ff;
last = i;
}
int len = last + 1;
for(int i = last + 1; i < n; i++) {
sum -= w_sort[i - len].ff;
sum += w_sort[i].ff;
if(sum >= l) {
for(int j = i - len + 1; j <= i; j++) ans.push_back(w_sort[j].ss);
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... |