Submission #385955

#TimeUsernameProblemLanguageResultExecution timeMemory
385955ismoilovDetecting Molecules (IOI16_molecules)C++14
9 / 100
2 ms384 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define pb push_back vector<int> find_subset(int l1, int u, vector<int> w) { int n = w.size(), ans = 0; set <int> s; sort(all(w)); int l = 0, r = 0; while(l < n && r < n) { if(ans < l1) { ans += w[r], s.insert(r), r ++; } if(ans > u) ans -= w[l], s.erase(l), l ++; if(ans >= l1 && ans <= u) break; } if(ans > u || ans < l1) s.erase(all(s)); vector <int> x; for(auto it : s) x.pb(it); return x; }
#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...