Submission #623020

#TimeUsernameProblemLanguageResultExecution timeMemory
623020Minindu2006Detecting Molecules (IOI16_molecules)C++14
100 / 100
55 ms8204 KiB
#include "molecules.h" #include <bits/stdc++.h> #define ll long long using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll, int>> ww; int sz = w.size(); for(int i=0;i<sz;i++) ww.push_back({(ll)w[i], i}); sort(ww.begin(), ww.end()); int a = 0, b = 0; ll csum = ww[0].first; int can = -1; while(b < sz) { if(csum >= l && csum <= u) { can = 1; break; } if(csum < l) { b++; if(b == sz) break; csum += ww[b].first; } else if(csum > u) { csum -= ww[a].first; a++; } } vector<int> ans; if(can == -1) 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...