Submission #197491

#TimeUsernameProblemLanguageResultExecution timeMemory
197491handlenameDetecting Molecules (IOI16_molecules)C++17
100 / 100
74 ms6252 KiB
//#include "molecules.h" #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> > wpos; for (int i=0;i<n;i++){ wpos.push_back(make_pair(w[i],i)); } sort(wpos.begin(),wpos.end()); int maxsize=0; long long tempsum=0; while (tempsum<=u && maxsize<n){ tempsum+=wpos[maxsize].first; maxsize++; } if (tempsum>u) maxsize--; deque<int> ans; vector<int> temp; long long sum=0; for (int i=0;i<maxsize;i++){ ans.push_back(wpos[i].second); sum+=wpos[i].first; } if (sum>=l){ vector<int> realans; for (auto i:ans) realans.push_back(i); return realans; } for (int i=maxsize;i<n;i++){ ans.push_back(wpos[i].second); ans.pop_front(); sum-=wpos[i-maxsize].first; sum+=wpos[i].first; if (sum>=l){ vector<int> realans; for (auto i:ans) realans.push_back(i); return realans; } } if (sum>=l){ vector<int> realans; for (auto i:ans) realans.push_back(i); return realans; } else return temp; }
#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...