# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
787019 | hariaakas646 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
vi find_subset(int l, int u, vi w)
{
int n = w.size();
sort(all(w));
vi out = {};
int id = 0;
int v = 0;
while (id < n && v <= l)
{
v += w[id];
out.pb(id);
id++;
}
if (v < l)
{
out = {};
return out;
}
else
{
if (v <= u)
{
return out;
}
id--;
v -= w[id];
out.pop_back();
int k = 0;
for (int i = n - 1; i >= id; i--)
{
if (v >= l)
break;
if (k >= out.size())
break;
v += w[i] - w[k];
out[k] = i;
k++;
}
if (v >= l)
{
return out;
}
else
{
out = {};
return out;
}
}
}
int main()
{
vi vec = {10, 10, 10};
vi out = find_subset(10, 20, vec);
for (auto e : out)
cout << e << " ";
}