Submission #890228

#TimeUsernameProblemLanguageResultExecution timeMemory
890228MercubytheFirstDetecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms348 KiB
#include "molecules.h" #include<algorithm> #include<assert.h> #include<numeric> #include<iostream> using namespace std; using ll = long long; vector<int> find_subset(int weight_low, int weight_hi, vector<int> w) { int n = w.size(); vector<pair<int, int> > v(n); for(int i = 0; i < n; ++i) v[i] = {w[i], i}; sort(v.begin(), v.end()); ll sum = 0, l = 0, r = 0; while(sum < weight_low or weight_hi < sum){ if(sum < weight_low){ if(r >= n) return vector<int>(); sum += v[r].second; r++; } else if(weight_hi < sum){ // assert(l <= r); sum -= v[l].second; l++; } // else // assert(false); } vector<int> ans; if(weight_low <= sum and sum <= weight_hi){ for(int i = l; i <= r; ++i){ ans.push_back(v[i].second); } } 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...