# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729030 | grogu | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 212 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>
#define endl '\n'
#define here cerr<<"=========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define ll long long
#define pb push_back
#define popb pop_back
#define all(a_) a_.begin(),a_.end()
#define pll pair<ll,ll>
#define sc second
#define fi first
using namespace std;
#define maxn 200005
ll n;
pll a[maxn];
ll last[maxn];
ll l,r;
vector<int> find_subset(int L, int R, vector<int> w) {
n = w.size(); l = L; r = R;
for(ll i = 1;i<=n;i++){
a[i].fi = w[i-1];
a[i].sc = i-1;
if(a[i].fi>=l&&a[i].fi<=r) return {i-1};
}
sort(a+1,a+1+n);
reverse(a+1,a+1+n);
set<pll> s; s.insert({0,0});
for(ll i = 1;i<=n;i++){
ll x = a[i].fi;
auto it = s.lower_bound({r-x+1,0});
if(it!=s.begin()){
it--;
ll cur = it->fi + x;
//cerr<<"i: "<<i<< " "<<cur<<endl;
if(cur>=l){
last[i] = it->sc;
ll k = i;
vector<int> ans;
while(k){
cur-=a[k].fi;
ans.pb(a[k].sc);
k = last[k];
if(cur==0) break;
}
sort(all(ans));
return ans;
}
last[i] = it->sc;
s.insert({cur,i});
}
s.insert({x,i});
}
return {};
}
/**
4 15 17
6 8 8 7
4 14 15
5 5 6 6
4 10 20
15 17 16 18
**/
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... |