Submission #70971

#TimeUsernameProblemLanguageResultExecution timeMemory
70971RezwanArefin01Detecting Molecules (IOI16_molecules)C++17
46 / 100
322 ms1680 KiB
#include <bits/stdc++.h> using namespace std; const int N = 10010; int need[N]; vector<int> v; vector<int> find_subset(int l, int u, vector<int> w) { memset(need, 63, sizeof need); need[0] = -1; v.push_back(0); for(int i = 0; i < w.size(); i++) { for(int j = 0, sz = v.size(); j < sz; j++) { int t = v[j] + w[i]; if(t > u) continue; if(need[t] <= i) continue; need[t] = i; v.push_back(t); } } sort(v.begin(), v.end()); auto x = lower_bound(v.begin(), v.end(), l); if(x == v.end()) return {}; int X = *x; vector<int> ans; for(int i = w.size() - 1; i >= 0; i--) { if(X >= w[i] && need[X - w[i]] < i) { X -= w[i]; ans.push_back(i); } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < w.size(); 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...