제출 #717603

#제출 시각아이디문제언어결과실행 시간메모리
717603ToxtaqDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms300 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int r, vector<int>w){ int n = w.size(); vector<bool>table(r + 1); vector<int>par(r + 1, -1); table[0] = 1; for(int i = 0;i < n;++i){ for(int j = r;j >= 1;--j){ if(j - w[i] >= 0 && table[j - w[i]]){ table[j] = 1; par[j] = i; } } } int num = -1; for(int i = l;i <= r;++i){ if(table[i]){ num = i; break; } } vector<int>ans; if(num < 0)return ans; while(par[num] != -1){ ans.push_back(par[num]); num -= w[par[num]]; } return ans; } //int main() //{ // int l, r, n; // cin >> l >> r >> n; // vector<int>v(n); // for(int i = 0;i < n;++i)cin >> v[i]; // vector<int>ans = find_subset(l, r, v); // for(int i : ans)cout << i << " "; //}
#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...