Submission #843645

#TimeUsernameProblemLanguageResultExecution timeMemory
843645Mr_HusanboyDetecting Molecules (IOI16_molecules)C++17
100 / 100
40 ms4956 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; template<typename T> int len(T &a){return a.size();} #define all(a) (a).begin(), (a).end() vector<int> find_subset(int a, int b, vector<int> w) { int n = len(w); vector<int> p(n); iota(all(p), 0); sort(all(p), [&](int i, int j){ return w[i] < w[j]; }); int l = 0, r = 0; long long cur = 0; queue<int> q; while(r < n){ cur += w[p[r]]; q.push(p[r]); while(l <= r && cur > b) cur -= w[p[l ++]], q.pop(); if(cur >= a) break; r ++; } vector<int> ans; if(cur >= a){ while(!q.empty()) ans.push_back(q.front()), q.pop(); } 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...