# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
972412 | Tanos | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define el "\n"
#define pb push_back
#define pp pop_back
#define pii pair <int, int>
#define pll pair <ll, ll>
#define ibase ios_base::sync_with_stdio(0), cin.tie(0);
const int N = 5e5 + 5, M = 1e3 + 5, pw = 31;
const ll MAX = 1e15, inf = 1e9 + 7;
vector <int> find_subset(ll l, ll u, vector <int> a) {
int n = a.size();
vector<pair <int, int>> p;
for (int i = 0; i < n; i++) {
p.pb({a[i], i});
}
sort(p.begin(), p.end());
ll sum = 0, j = 0, last = 0;
for (int i = 0; i < n; i++) {
sum += p[i].x;
last = i;
if (sum >= l && sum <= u) {
break;
}
else if (sum >= l) {
j = 0;
while (sum > u)
sum -= p[j++].x;
if (sum >= l)
break;
}
}
vector <int> ans;
ans.clear();
if (l > sum || sum > u)
return ans;
for (int i = j; i <= last; i++)
ans.pb(p[i].y);
return ans;
}