# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
948395 | Syrius | 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 <bits/stdc++.h>
using namespace std;
#define int long long
#define pint pair < int , int >
#define ll long long
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL); cin.tie(NULL)
const int inf = 1e9 + 9;
const int mxn = 2e5 + 2;
const int mod = 1e9 + 7;
vector < int > find_subset(int l , int r , vector < int > w) {
int n = w.size();
vector < pint > v;
for (int i = 0; i < n; i++) {
v.push_back({w[i] , i});
}
sort(v.begin() , v.end());
vector < int > ans , rep , emp;
emp.resize(0);
int id1 = 0 , sum = 0;
while (id1 < n) {
sum += v[id1].ff;
ans.push_back(v[id1].ss);
if (sum >= l) break;
id1++;
}
if (id1 == n) return emp;
if (sum <= r) return ans;
sum -= v[id1].ff;
ans.pop_back();
id1--;
int id2 = n-1;
while (id1 >= 0) {
sum += v[id2].ff - v[id1].ff;
ans.pop_back();
rep.push_back(v[id2].ss);
id2--;
id1--;
if (sum >= l && sum <= r) {
for (int i : rep) ans.push_back(i);
return ans;
}
}
return emp;
}