Submission #1062142

#TimeUsernameProblemLanguageResultExecution timeMemory
1062142Hectorungo_18Detecting Molecules (IOI16_molecules)C++14
69 / 100
1058 ms5592 KiB
#include <bits/stdc++.h> using namespace std; mt19937 gnd(time(nullptr)); // #define int long long vector<int> find_subset(int l, int r, vector<int> w){ int n = w.size(); vector<pair<int, int>> v(n); for(int i = 0; i < n; i++){ v[i]={w[i], i}; } sort(v.begin(), v.end()); int aux = 0; vector<int> ba(n), bb(n); for(int i = 0; i < n; i++){ ba[i]=v[i].first; bb[i]=v[i].second; } vector<int> sol; for(int i = n-1; i >= 0; i--){ if(ba[i] > r) continue; sol.clear(); sol.push_back(bb[i]); aux = ba[i]; bool im = 1; int fal = l-aux; int cp = i; while(l > aux){ fal = r-aux; auto it = upper_bound(ba.begin(), ba.begin()+cp, fal); if(it == ba.end() || it == ba.begin()){ im = 0; break; } else{ // if(it == ba.begin()+cp) it--; cp = it-ba.begin()-1; aux+=ba[cp]; sol.push_back(bb[cp]); } if(aux >= l && aux <= r) break; // cp++; if(cp == 0){ im = 0; break; } } if(im == 0) continue; if(aux <= l && aux >= r) break; break; } if(aux < l || aux > r){ sol.clear(); } return sol; }
#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...