# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
720505 | joelgun14 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
// between l and u
// pilih sum terkecil, terus nanti
sort(w.begin(), w.end());
// cari w sesuai buat antara u l
// cari first bigger than u, berarti countnya itu satu kurang dr
long long sum = 0;
int cnt = w.size();
for(int i = 0; i < w.size(); ++i) {
sum += w[i];
if(sum > u) {
cnt = i;
break;
}
}
if(cnt == 0)
return vector<int>(0);
multiset<int> s;
sum = 0;
for(int i = 0; i < cnt; ++i) {
sum += w[i];
s.insert(w[i]);
}
multiset<int> unused;
for(int i = cnt; i < w.size(); ++i) {
// try to
if(sum >= l)
break;
if(sum < l) {
// coba increase to smallest above l
s.insert(w[i]);
sum += w[i];
sum -= *s.begin();
s.erase(s.begin());
}
}
if(sum >= l && sum <= u) {
vector<int> ans;
for(int i = 0; i < w.size(); ++i) {
if(s.find(w[i]) != s.end()) {
ans.push_back(i);
s.erase(s.find(w[i]));
}
}
return ans;
}
else {
return vector<int>(0);
}
}
Compilation message (stderr)
# | 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... |