# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218938 | 2020-04-03T08:25:19 Z | yayups | Detecting Molecules (IOI16_molecules) | C++11 | 0 ms | 0 KB |
// created 01 FEB 2018 // updated JUNE 2018 // updated JULY 2018 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <cstring> #include <map> #include <cstdlib> #include <ctime> #include <cassert> #include <bitset> #include <fstream> #include <sstream> #include <cstdlib> #include <list> #include <stdexcept> #define N 200000 using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n=w.size(); vector<int> v(n); vector<int> result; v[0]=w[0]; for(int i=0;i<n;i++) { v[i] = v[i-1]+w[i]; } vector<int>::iterator low,up; int a,b=0; int t; //it's going to be v[b]-v[a] for(a=-1;a<n;a++) { if(a==-1) { t=0; } else { t=v[a]; } low=lower_bound(v.begin()+(1+a),v.end(),l+t); up =upper_bound(v.begin()+(1+a),v.end(),u+t); if(low-v.begin()<up-v.begin()) { b=low-v.begin(); break; } } //cout << a<<endl<<b<<endl; if(a==n) { return 0; } for(int i=0;i<b-a;i++) { result.push_back(a+1+i); } return result; }