제출 #405908

#제출 시각아이디문제언어결과실행 시간메모리
405908donghwa722Detecting Molecules (IOI16_molecules)C++14
0 / 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+1); 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+1); return re; } int s=0,e=k-1,c=mn; while(1){ if((ll)l<=c&&c<=(ll)u){ vector<int> re; for(int i=s;i<=e;i++) re.push_back(nw[i].second+1); return re; } if(c<(ll)l) c+=nw[++e].first; else if(c>(ll)u) c-=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...