| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332162 | Chinguun | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 0 KiB |
#include "molecules.h"
// #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define meta int tm = (tl + tr) / 2, x = i * 2 + 1, y = x + 1
const int N = 2e5 + 7;
const int TN = 4 * N;
const int oo = 1e18;
const int mod = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vii v;
vi empty, ans;
for (int i = 0; i < w.size(); i++) {
v.pb({w[i], i + 1});
}
sort (v.begin(), v.end());
int sum = v[0].ff, tl = 0, tr = 0;
ans.pb(v[0].ss);
int cnt = 0;
while (1) {
cnt++;
if (l <= sum && sum <= u) return ans;
if (sum < l) {
tr++;
if (tr >= w.size()) return empty;
ans.pb(v[tr].ss);
sum += v[tr].ff;
}
else {
ans.erase(ans.begin());
sum -= v[tl].ff;
tl++;
if (tl >= w.size()) return empty;
}
// cout << tl << ' ' << tr << ' ' << sum << '\n';
}
}