Submission #853185

#TimeUsernameProblemLanguageResultExecution timeMemory
853185parsadox2Detecting Molecules (IOI16_molecules)C++14
69 / 100
45 ms4904 KiB
#include <bits/stdc++.h> using namespace std; vector <int> find_subset(int l , int u , vector <int> w) { vector <int> t = w; int r = u; vector <pair<int ,int>> ar; int n = t.size(); for(int i = 0 ; i < n ; i++) ar.push_back({t[i] , i}); sort(ar.begin() , ar.end()); vector <int> res; int num = 0 , sum = 0; for(int i = n - 1 ; i > -1 ; i--) { sum += ar[i].first; num++; if(sum >= l) break; } num--; if(sum < l) return res; int sum2 = 0; for(int i = 0 ; i <= num ; i++) sum2 += ar[i].first; if(sum2 > r) return res; int las = n - 1; while(sum2 < l) { sum2 += (ar[las].first - ar[num].first); num--; res.push_back(ar[las].second); las--; } for(int i = num ; i >= 0 ; i--) res.push_back(ar[i].second); reverse(res.begin() , res.end()); return res; }
#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...