Submission #405906

#TimeUsernameProblemLanguageResultExecution timeMemory
405906donghwa722Detecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms204 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,int> pll; vector<pll> nw; int n; std::vector<int> find_subset(int l, int u, std::vector<int> w) { n=(int)w.size(); for(int i=0;i<n;i++) nw.push_back({(ll)w[i],i}); sort(nw.begin(),nw.end()); ll mn=0,mx=0; for(int k=0;k<n;k++){ mn+=nw[k].first; mx+=nw[n-k-1].first; if((ll)u<mn) return vector<int>(0); if(mx<(ll)l) continue; if((ll)l<=mn&&mn<=(ll)u){ vector<int> re; for(int i=0;i<=k;i++) re.push_back(nw[i].second); return re; } if((ll)l<=mx&&mx<=(ll)u){ vector<int> re; for(int i=k;i>=0;i--) re.push_back(nw[n-i-1].second); return re; } int s=0,e=k-1; while(1){ if((ll)l<=mn&&mn<=(ll)u){ vector<int> re; for(int i=s;i<=e;i++) re.push_back(nw[i].second); return re; } if(mn<(ll)l) mn+=nw[++e].first; else if(mn>(ll)u) mn-=nw[s++].first; } } return vector<int>(0); }
#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...