Submission #309486

#TimeUsernameProblemLanguageResultExecution timeMemory
309486radaiosm7Detecting Molecules (IOI16_molecules)C++98
69 / 100
60 ms4092 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> ans; vector<pair<int,int>> p; int i, j, n, sum; std::vector<int> find_subset(int l, int u, std::vector<int> w) { n = w.size(); for (i=0; i < n; i++) { p.push_back(make_pair(w[i], i)); } sort(p.begin(), p.end ()); i = 0; j = 0; sum = p[0].first; while (j < n) { if (l <= sum && sum <= u) { break; } else if (sum < l) { if (j+1 == n) { break; } sum += p[++j].first; } else { sum -= p[i++].first; } } if (l <= sum && sum <= u) { for (int x=i; x <= j; x++) { ans.push_back(p[x].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...