Submission #599182

#TimeUsernameProblemLanguageResultExecution timeMemory
599182JomnoiDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector <int> find_subset(int L, int U, vector <int> w) { int n = w.size(); vector <pair <int, int>> weights; for(int i = 0; i < n; i++) { weights.emplace_back(w[i], i); } sort(weights.begin(), weights.end()); long long sum = 0; int l = 0, r = 0; while(l < n or r < n) { if(r < n and sum < L) { sum += weights[r].first; r++; } else if(l < n and sum > U) { sum -= weights[l].first; l++; } else { vector <int> ans; for(int i = l; i < r; i++) { ans.push_back(weights[i].second); } return ans; } } return vector <int> (); }
#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...