# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249810 | hhh07 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <cmath>
#include <climits>
#include <cstring>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
vi find_subset(ll l, ll u, vi w){
vi result;
ll n = w.size();
ii x[n];
for (ll i = 0; i < n; i++)
x[i] = {w[i], i};
sort(x, x + n);
ll s = 0, curr = 0;
bool t = false;
for (ll i = 0; i < n; i++){
w[i] = x[i].first;
s += w[i];
curr = i;
if (s >= l && s <= u){
for (ll j = 0; j <= i; j++)
result.push_back(x[j].second);
return result;
}
if (s >= l){
s -= w[i];
t = true;
break;
}
}
if (!t)
return result;
for (ll i = curr; i < n; i++){
w[i] = x[i].first;
s += w[i] - w[i - curr];
if (s >= l && s <= u){
for (ll j = i - curr + 1; j <= i; j++)
result.push_back(x[j].second);
return result;
}
}
return result;
}