Submission #1102146

# Submission time Handle Problem Language Result Execution time Memory
1102146 2024-10-17T14:40:42 Z akzytr Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 336 KB
#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();
	int dp[n + 1][u + 1];

	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= u; j++) {
			dp[i][j] = -1;
		}
	}

	dp[0][0] = 0;
	for(int i = 1; i <= n; i++) {
		for(int s = 0; s <= u; s++) {
			if(s < w[i - 1]) {
				dp[i][s] = dp[i - 1][s];
			}

			else if(dp[i - 1][s - w[i - 1]] != -1) {
				dp[i][s] = i;
			} else {
				dp[i][s] = dp[i - 1][s];
			}
		}
	}

	for(int i = l; i <= u; i++) {
		if(dp[n][i]) {
			int idx = dp[n][i];
			int s = i;
			while(idx != 0) {
				result.push_back(idx - 1);
				s -= w[idx - 1];
				idx = dp[idx][s];
			}
			break;
		}
	}

	return result;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB item #11 is taken twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -