이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
struct we{
int w, id;
bool operator<(const we& o) {
return w<o.w;
}
};
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
vector<we> mw;
mw.reserve(n); for(int i=0;i<n;++i) mw.push_back({w[i],i});
sort(mw.begin(),mw.end());
ll sum =0;
for(int i=0,j=0;i<n;++i) {
while(j<n and sum+mw[j].w<=u) {
++j;
sum+=mw[j].w;
}
if(l<=sum and sum<=u) {
vi ans;
for(int p = i;p<j;++p) {
ans.push_back(mw[p].id);
}
return ans;
}
sum-=mw[i].w;
}
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... |