이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
#include <cassert>
#define ll long long
#define ln "\n"
#define ff first
#define ss second
#define ld long double
const ll INF = 2e18;
const ll MOD = 1e9+7;
using namespace std;
vector<ll> find_subset(int l, int u, std::vector<int> w) {
ll n = w.size();
vector<pair<ll, ll>> bw(n);
for (ll i=0; i<n; i++){
bw[i] = {w[i], i};
}
sort(bw.rbegin(), bw.rend());
vector<ll> ind;
ll sum = 0;
ll cp = 0;
while (cp<n and sum+bw[cp].ff<=u){
ind.push_back(bw[cp].ss);
sum+=bw[cp].ff;
cp++;
}
ll ccp = n-1;
while (ccp>cp and sum+bw[ccp].ff<=l){
ind.push_back(bw[ccp].ss);
sum+=bw[ccp].ff;
ccp--;
}
if (sum>=l and sum<=u){
return ind;
}else return vector<ll>(0);
}
# | 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... |