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