Submission #388574

#TimeUsernameProblemLanguageResultExecution timeMemory
388574aarrDetecting Molecules (IOI16_molecules)C++14
100 / 100
79 ms5192 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; const int N = 200 * 1000 + 5; pair <int, int> a[N]; long long ps[N]; std::vector<int> find_subset(int l, int r, std::vector<int> w) { vector <int> ans; int n = w.size(); for (int i = 1; i <= n; i++) { a[i] = {w[i - 1], i - 1}; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { ps[i] = ps[i - 1] + a[i].first; } // for (int i = 1; i <= n; i++) { // cout << "71 " << a[i].first << " " << a[i].second << endl; // } for (int i = 0; i < n; i++) { int x = lower_bound(ps + i, ps + n + 1, ps[i] + l) - ps; if (x <= n && ps[x] - ps[i] <= r) { for (int j = i + 1; j <= x; j++) { ans.push_back(a[j].second); } return ans; } } 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...