Submission #1024229

#TimeUsernameProblemLanguageResultExecution timeMemory
1024229vaneaDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { set<pair<int, int>> s; vector<pair<ll, int>> v; int n = w.size(); for(int i = 0; i < n; i++) { v.push_back({w[i], i}); } sort(v.begin(), v.end()); ll sum = 0; for(int i = 0; i < n; i++) { sum += v[i].first; s.insert(v[i]); if(sum > u) { sum -= s.begin()->first; s.erase(s.begin()); } if(l <= sum && sum <= u) { vector<int> res; for(auto x : s) res.push_back(x.second); return res; } } } /* int main() { vector<int> ans = find_subset(15, 17, {6, 8, 8, 7}); for(auto it : ans) { cout << it << ' '; } }*/

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:25: warning: control reaches end of non-void function [-Wreturn-type]
    7 |     set<pair<int, int>> s;
      |                         ^
#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...