Submission #557654

#TimeUsernameProblemLanguageResultExecution timeMemory
557654Talha_TakiDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; typedef pair <int, int> pii; std::vector<int> find_subset(int l, int u, std::vector<int> W) { vector <int> ret; int n = W.size(); vector <pii> w(n); for(int i = 0; i < n; ++i) { w[i] = {W[i], i}; } sort(w.begin(), w.end()); ll sum = 0; int left = 0, right = -1; while (right < n-1) { sum += w[++right].first; while (sum > u && left <= right) { sum -= w[left++].first; } if (l <= sum && sum <= u) { break; } } if (l <= sum && sum <= u) { while (left <= right) ret.push_back(left++); } return ret; }
#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...