Submission #815522

#TimeUsernameProblemLanguageResultExecution timeMemory
815522TheSahibDetecting Molecules (IOI16_molecules)C++14
100 / 100
39 ms6216 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int v, int u, vector<int> w) { int n = w.size(); long long sum = 0; vector<pair<int, int>> arr; for (int i = 0; i < n; i++) { arr.push_back({w[i], i}); } sort(arr.begin(), arr.end()); int l = 0, r = 0; while(true){ if(sum > u){ if(l == r) return {}; sum -= arr[l++].first; } else if(sum < v){ if(r == n){ return {}; } sum += arr[r++].first; } else{ break; } } vector<int> ans; for(int i = l; i < r; ++i){ ans.push_back(arr[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...