# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
385946 | ismoilov | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 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<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fv(c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first
vector<int> find_subset(int l1, int u, vector<int> &w) {
ll n = w.size(), ans = 0;
//cin >> n >> l1 >> u;
set <ll> s;
/*fp(i,0,n)
cin >> w[i];*/
sort(all(w));
int l = 0, r = 0;
while(l < n && r < n)
{
while(ans < l1)
{
ans += w[r], r ++, s.insert(r-1);
//continue;
}
if(ans >= l1 && ans <= u)
break;
while(ans > u)
ans -= w[l], l ++, s.erase(l-1);
}
if(ans > u || ans < l1)
s.erase(all(s));
//cout << ans << "\n";
vector <int> x;
for(auto it : s)
x.pb(it+1);
return x;
//return vector<int>(0);
}