Submission #651358

#TimeUsernameProblemLanguageResultExecution timeMemory
651358ayallaDetecting Molecules (IOI16_molecules)C++14
100 / 100
54 ms8252 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long int vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<ll, int>> s; for (int i = 0; i < n; i++) s.push_back({w[i], i}); sort(s.begin(), s.end()); vector<bool> vis(n, 0); vector<int> ans; ll sum = 0, j = 0; for (int i = 0; i < n; i++) { while (j < n && sum < l) { sum += s[j].first; vis[s[j].second] = 1; j++; } if (sum >= l && sum <= u) { for (int i = 0; i < n; i++) { if (vis[i]) ans.push_back(i); } break; } sum -= s[i].first; vis[s[i].second] = 0; } return ans; }
#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...