Submission #1072312

#TimeUsernameProblemLanguageResultExecution timeMemory
1072312ivazivaDetecting Molecules (IOI16_molecules)C++14
100 / 100
44 ms6348 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int,int>> vec; vec.push_back({0,0}); int n=w.size(); for (int i=0;i<n;i++) vec.push_back({w[i],i}); sort(vec.begin(),vec.end()); int levo=1,desno=1; long long val=vec[1].first; bool resenje=false; while (true) { if (val>=l and val<=u) {resenje=true;break;} if (val<l and desno<n) {desno++;val+=vec[desno].first;} else if (val<l and desno==n) break; else if (val>u and levo<desno) {val-=vec[levo].first;levo++;} else if (val>u and levo==desno) break; } vector<int> ans; if (!resenje) return ans; for (int i=levo;i<=desno;i++) ans.push_back(vec[i].second); 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...