Submission #70968

#TimeUsernameProblemLanguageResultExecution timeMemory
70968RezwanArefin01Detecting Molecules (IOI16_molecules)C++17
0 / 100
2 ms556 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1010; bool dp[110][N]; vector<int> find_subset(int l, int u, vector<int> W) { vector<int> a = {0}; for(int x : W) a.push_back(x); int n = a.size() - 1; for(int i = 1; i <= n; i++) if(l <= a[i] && a[i] <= u) return {i}; dp[0][0] = 1; for(int i = 1; i <= n; i++) { for(int j = 0; j <= u; j++) { dp[i][j] = dp[i - 1][j]; if(j >= a[i]) dp[i][j] |= dp[i - 1][j - a[i]]; } } int w = -1; for(int i = l; i <= u; i++) if(dp[n][i]) w = i; if(w == -1) return {}; vector<int> v; for(int i = n; i >= 1; i--) { if(w >= a[i] && dp[i - 1][w - a[i]]) { v.push_back(i); w -= a[i]; } cout << i << " " << w << endl; } return v; }
#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...