Submission #439474

#TimeUsernameProblemLanguageResultExecution timeMemory
439474IdkwhoamiDetecting Molecules (IOI16_molecules)C++14
19 / 100
1 ms240 KiB
#include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); vector<pair<int, int>> v(n); vector<int> pf(n); for(int i = 0;i<n;i++){ v[i].first = w[i]; v[i].second = i; } pf[0] = v[0].first; sort(v.begin(), v.end()); for(int i = 1;i<n;i++)pf[i] = pf[i-1] + v[i].first; map<int, int> pos; for(int i = 0;i<n;i++){ pos[pf[i]] = i; } for(int i = 0;i<n;i++){ if(pf[i] < l)continue; if(pf[i] >= l && pf[i] <= u){ vector<int> a(i+1); for(int j = 0;j<=i;j++)a[j] = v[j].second; return a; } int req = pf[i] - u; auto itr = lower_bound(pf.begin(), pf.end(), req); if(pf[i] - *itr >= l && pf[i] - *itr <= u){ vector<int> a(i - pos[*itr]); for(int j = pos[*itr] + 1, k = 0; j <= i;j++,k++)a[k] = v[j].second; return a; } } return vector<int>{}; }
#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...