Submission #1098051

#TimeUsernameProblemLanguageResultExecution timeMemory
1098051dzhoz0Detecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms348 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = (int)w.size(); vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { a[i].first = w[i]; a[i].second = i; } sort(a.begin(), a.end()); vector<long long> ps(n); ps[0] = a[0].first; for (int i = 1; i < n; i++) { ps[i] = ps[i - 1] + a[i].first; } if(*lower_bound(ps.begin(), ps.end(), l) <= u) { vector<int> res; for (int i = 0; i < n; i++) { res.push_back(i); if(ps[i] >= l && ps[i] <= u) break; return res; } } for (int i = 0; i < n; i++) { auto it = lower_bound(ps.begin(), ps.end(), ps[i] + l); if(it == ps.end()) continue; if(*it - ps[i] <= u) { int id = it - ps.begin(); vector<int> res; for (int j = i + 1; j <= id; j++) { res.push_back(j); } return res; } } return std::vector<int>(0); }
#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...