Submission #1132194

#TimeUsernameProblemLanguageResultExecution timeMemory
1132194lopkusDetecting Molecules (IOI16_molecules)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { sort(w.begin(), w.end()); int n = w.size(); for(int i = 0; i < n; i++) { if(w[i] >= l && w[i] <= u) { return {w[i]}; } } int idx = - 1; for(int i = 0; i < n; i++) { if(w[i] < l) { idx = i; } } if(idx == - 1) { return {}; } vector<int> p; for(int i = idx; i >= 0; i--) { if(u - l >= w[idx] - w[i]) { p.push_back(w[i]); } } sort(p.begin(), p.end()); vector<int> ans; vector<int> was(n, 0); while(l > 0) { int o = - 1; for(int i = 0; i < p.size(); i++) { if(was[i]) { continue; } if(p[i] >= l && p[i] <= u) { o = p[i]; break; } } if(o != - 1) { ans.push_back(o); return ans; } for(int i = 0; i < p.size(); i++) { if(was[i]) { continue; } if(p[i] < l) { o = i; } } if(o == - 1) { return {}; } l -= p[o]; u -= p[o]; was[o] = 1; ans.push_back(p[o]); } return ans; }

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...