Submission #418779

#TimeUsernameProblemLanguageResultExecution timeMemory
418779SuhaibSawalha1Detecting Molecules (IOI16_molecules)C++17
69 / 100
55 ms5560 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int r, vector<int> w) { vector<array<int, 2>> a; int n = w.size(); for (int i = 0; i < n; ++i) { a.push_back({w[i], i}); } sort(a.begin(), a.end()); int L = 0, R = 0, sum = a[0][0]; while (R < n) { if (sum > r) { sum -= a[L][0]; ++L; } else if (sum < l) { ++R; sum += a[R][0]; } else { vector<int> ans; for (int i = L; i <= R; ++i) { ans.push_back(a[i][1]); } return ans; } } return {}; }
#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...