Submission #987600

#TimeUsernameProblemLanguageResultExecution timeMemory
987600TsaganaDetecting Molecules (IOI16_molecules)C++14
100 / 100
46 ms4164 KiB
#include "molecules.h" #include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define lnl long long #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define eb emplace_back #define F first #define S second using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int, int>> ww; int n = w.size(); lnl sum = 0; for (int i = 0; i < n; i++) {sum += w[i]; ww.pb({w[i], i});} sort(all(ww)); vector<int> id; for (int i = n - 1, j = n; i < j && i >= -1;) { while (sum > u && i >= 0) {sum -= ww[i].F; i--;} if (l <= sum && sum <= u) { for (int p = 0; p <= i; p++) id.pb(ww[p].S); for (int p = j; p < n; p++) id.pb(ww[p].S); return id; } j--; sum += ww[j].F; } return 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...