# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
346735 | wwdd | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 380 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;
typedef long long ll;
typedef pair<ll,ll> pl;
//gross
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pl> wa;
for(int i=0;i<w.size();i++) {
wa.emplace_back(w[i],i);
}
sort(wa.begin(),wa.end());
int n = wa.size();
ll res = 0;
int pl = 0;
while(pl < wa.size() && res+wa[pl].first <= u) {
res += wa[pl].first;
pl++;
}
int pr = n-1;
int rs = 0;
while(pr >= n-pl && res+wa[pr].first-wa[pr-n+pl].first <= u) {
res += wa[pr].first-wa[pr-n+pl].first;
pr--;
rs++;
}
vector<int> ans;
cout << res << '\n';
if(res >= l && res <= u) {
for(int i=0;i<pl-rs;i++) {
ans.push_back(wa[i].second);
}
for(int i=0;i<rs;i++) {
ans.push_back(wa[n-i-1].second);
}
sort(ans.begin(),ans.end());
}
return ans;
}
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... |