# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135744 | 2019-07-24T10:28:38 Z | Runtime_error_ | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include "molecules.h" #include <bits/stdc++.h> using namespace std; const int inf = 2e5+9; int n,pre[inf]; pair<int,int> a[inf]; vector<int> find_subset(int l, int r, vector<int> w) { vector<int> ans; n = w.size(); for(int i=1;i<=n;i++) a[i] = make_pair(w[i-1],i-1); sort(a+1,a+1+n); for(int i=1;i<=n;i++) pre[i] = pre[i-1]+a[i].first; set<pair<int,int> > s; for(int i=1;i<=n;i++){ s.insert(make_pair(pre[i-1],i)); set< pair<int,int> > ::iterator it = s.lower_bound( make_pair( pre[i]-r , 0 ) ); if( it->first > pre[i] - l ) continue; for(int j = it->second ; j <= i ;j++){ ans.push_back(a[j].second); assert(a[j].seecond<n); } return ans; /*for(int j=i;j<=n;j++){ if(pre[j] - pre[i-1] >=l && pre[j] - pre[i-1] <= r){ for(int z=i;z<=j;z++) ans.push_back(a[z].second-1); return ans; } }*/ } return ans; }