제출 #765659

#제출 시각아이디문제언어결과실행 시간메모리
765659SanguineChameleonDetecting Molecules (IOI16_molecules)C++17
100 / 100
37 ms5588 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	vector<pair<int, int>> order(n);
	for (int i = 0; i < n; i++) {
		order[i].first = w[i];
		order[i].second = i;
	}
	sort(order.begin(), order.end());
	long long sum = 0;
	int rt = -1;
	for (int i = 0; i < n; i++) {
		while (sum < l && rt + 1 < n) {
			rt++;
			sum += order[rt].first;
		}
		if (l <= sum && sum <= u) {
			vector<int> res;
			for (int j = i; j <= rt; j++) {
				res.push_back(order[j].second);
			}
			return res;
		}
		sum -= order[i].first;
	}
	return vector<int>(0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...