| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1172522 | versesrev | Detecting Molecules (IOI16_molecules) | C++20 | 57 ms | 131072 KiB | 
// 21:19
#include <vector>
std::vector<int> find_subset(int low, int up, std::vector<int> w) {
  int n = w.size();
  std::vector<std::vector<int>> back(n, std::vector<int>(up + 1, -1));
  back[0][0] = 0;
  if (w[0] <= up) back[0][w[0]] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j <= up; ++j) {
      if (w[i] <= j and back[i - 1][j - w[i]] != -1) {
        back[i][j] = j - w[i];
      }
      else if (back[i - 1][j] != -1) {
        back[i][j] = j;
      }
      else back[i][j] = -1;
    }
  }
  
  std::vector<int> ans;
  int start_j = -1;
  int start_i = -1;
  for (int i = 0; i < n and start_i == -1; ++i) {
    for (int j = low ; start_j == -1 and j <= up; ++j) {
      if (back[i][j] != -1) {
        start_i = i;
        start_j = j;
      }
    }
  }
  if (start_i == -1) {
    return ans;
  }
  int cur_i = start_i;
  int cur_j = start_j;
  while (cur_j != 0) {
    if (back[cur_i][cur_j] == cur_j) {
      cur_i -= 1;
    }
    else {
      ans.push_back(cur_i);
      cur_j = back[cur_i][cur_j];
      cur_i -= 1;
    }
  }
  return ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
