제출 #821313

#제출 시각아이디문제언어결과실행 시간메모리
821313KerimDetecting Molecules (IOI16_molecules)C++17
46 / 100
1047 ms2388 KiB
#include "molecules.h" #include "bits/stdc++.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<bool> dp(u+1, false); vector<int> par(u+1); dp[0] = true; int sum = 0, n = w.size(); for (int j = 0; j < n; j++){ int x = w[j]; for (int i = sum; i >= 0; i--) if (i+x <= u and !dp[i+x] and dp[i]){ dp[i+x] = true; par[i+x] = j; } sum = min(u, sum+x); } for (int i = l; i <= u; i++) if (dp[i]){ vector<int> answer; int j = i; while (j){ answer.push_back(par[j]); j -= w[par[j]]; } return answer; } return vector<int>{}; }
#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...