# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218932 | 2020-04-03T08:19:09 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; int find_subset(int l, int u, int w[], int n, int result[]) { int prefix[N]; prefix[0]=w[0]; for(int i=0;i<n;i++) { prefix[i] = prefix[i-1]+w[i]; } vector<int> v(prefix,prefix+n); vector<int>::iterator low,up; int a,b=0; //it's going to be v[b]-v[a] for(a=0;a<n;a++) { cout << "a is " << a <<endl; low=lower_bound(v.begin()+a,v.end(),l+v[a]); up =upper_bound(v.begin()+a,v.end(),u+v[a]); 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[i]=a+1+i; } return b-a; }