Submission #777851

#TimeUsernameProblemLanguageResultExecution timeMemory
777851Minindu206Detecting Molecules (IOI16_molecules)C++14
100 / 100
41 ms6180 KiB
#include "molecules.h" #include<bits/stdc++.h> #define ll long long using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<pair<int, int>> ww; for(int i=0;i<n;i++) ww.push_back({w[i], i}); sort(ww.begin(), ww.end()); ll sum = ww[0].first; int a = 0, b = 0, pos = 0; while(a < n) { if(sum >= l && sum <= u) { pos = 1; break; } if(sum < l) { b++; if(b == n) break; sum += ww[b].first; } if(sum > u) { sum -= ww[a].first; a++; } } vector<int> ans; if(!pos) return ans; for(int i=a;i<=b;i++) ans.push_back(ww[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...