| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 335121 | blue | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <vector>
#include <algorithm>
using namespace std;
vector<int> W;
int n;
vector<int> find_subset(int l, int u, vector<int> w)
{
W = w;
n = w.size();
int i, x;
vector<int> I(n);
for(i = 0; i < n; i++) I[i] = i;
sort(I.begin(), I.end(), [] (int x, int y)
{
return W[x] < W[y];
});
int sum = 0;
vector<int> empty_res;
vector<int> res;
if(w[I[0]] > u) return empty_res;
for(x = 0; x < n && sum < l; x++)
{
i = I[x];
sum += w[i];
res.push_back(i);
}
if(sum < l) return empty_res;
x--;
sum -= x[I[x]];
res.pop_back();
res.push_back(I[n-1]);
return res;
}
