Submission #575344

#TimeUsernameProblemLanguageResultExecution timeMemory
575344srlabibDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms304 KiB
#/****Bismillahir rahmanir rahim****/ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<double> vd; #define All(a) a.begin(), a.end() template <typename T> void get_vector(T &a) { for (auto &e : a) cin >> e; } template <typename T> void put_vector(T a) { for (auto e : a) cout << e << " "; cout << endl; } vector<int> find_subset(int l, int u, vi w) { int n =w.size(); vi res; bool dp[n+1][u+1]; for(int i = 0; i<=n; i++)for(int j = 0; j<=u; j++)dp[i][j] = 0; dp[0][0] = 1; for(int i = 1; i<=n; i++){ for(int j = 0; j<=u; j++){ if(dp[i-1][j]){ dp[i][j] = 1; if(j+w[i-1]<=u){ dp[i][j+w[i-1]] = 1; } } if(dp[i][j]&&j>=l) { int x = j; while(x>0){ res.push_back(i); x -= w[i-1]; i--; } reverse(res.begin(),res.end()); return res; } } } return res; }
#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...