# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
265837 | amalla | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> find_subset(int l, int u, vector<int> w) {
int N = w.size();
vector<pair<int,int>> A(N);
for (int i = 0; i<N; ++i) {
A[i].first = w[i]; A[i].second = i;
}
sort(A.begin(), A.end());
ll sum = 0;
queue<int> q;
for (int i = 0; i<N; ++i) {
sum += A[i].first;
q.push(A[i].second);
while (sum>u) {
sum -= A[q.front()];
q.pop();
}
if (sum>=l) {
vector<int> Ans(q.size());
j = 0;
while(!q.empty()) {
Ans[j] = q.front(); q.pop();
++j;
}
return Ans;
}
}
return vector<int>(0);
}