# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961712 | ErJ | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 600 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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define pp pair<ll, ll>
#define inf 1000000000000000;
#define vvi vector<vi>
#define vp vector<pp>
#define rep(i, n) for(int i = 0; i < n; i++)
#define mod 1000000007
vector<int> result;
vector<int> find_subset(int l, int r, vector<int> w) {
sort(w.begin(), w.end());
ll n = w.size();
vi pref(n), suff(n);
pref[0] = w[0];
suff[0] = w[n - 1];
rep(i, n - 1) {
pref[i + 1] = pref[i] + w[i + 1];
suff[i + 1] = suff[i] + w[n - i - 2];
}
set<ll> ans;
result.clear();
rep(i, n) {
ans.insert(i);
if (pref[i] <= r && suff[i] >= l) {
result.clear();
ll akt = pref[i];
if (pref[i] >= l) {
auto it = ans.begin();
for (ll j = 0; j < ans.size(); j++) {
result.push_back(*it);
it++;
}
}
else {
for (int j = i; j >= 0; j--) {
akt -= w[j];
ans.erase(j);
ll left = i;
ll right = n - (i - j);
ll hledam = r - akt;
while (right > left + 1) {
ll mid = (right + left) / 2;
if (w[mid] > hledam) {
right = mid;
}
else {
left = mid;
}
}
akt += w[left];
ans.insert(left);
if (l <= akt && akt <= r) {
auto it = ans.begin();
for (ll j = 0; j < ans.size(); j++) {
result.push_back(*it);
it++;
}
}
}
}
break;
}
}
return result;
}
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... |