Submission #1102183

#TimeUsernameProblemLanguageResultExecution timeMemory
1102183akzytrDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms588 KiB
// #include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	vector<int> result;

	int n = w.size();
	bitset<30002> dp;

	dp[0] = 1;

	for(int i = 0; i < n; i++) {
		dp |= (dp << w[i]);
	}

	for(int i = l; i <= u; i++) {
		if(dp[i]) {
			int cur_s = i;
			for(int j = n - 1; j >= 0; j--) {
				if(cur_s - w[j] >= 0 && dp[cur_s - w[j]]) {
					cur_s -= w[j];
					result.push_back(j);
				}
				if(cur_s == 0) {
					break;
				}
			}
			break;
		}
	}

	return result;
}
#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...