Submission #661320

#TimeUsernameProblemLanguageResultExecution timeMemory
661320GoldLightDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int r, vector<int> w){ vector<pair<int,int>> v; int n=w.size(); for(int i=0; i<n; i++){ v.push_back({w[i], i}); } sort(v.begin(), v.end()); long long sum=0; vector<int> ans; for(int i=0; i<n; i++){ sum+=v[i].first; if(sum>=l){ if(sum<=r){ for(int j=0; j<=i; j++) ans.push_back(v[j].second); return ans; } } else{ int pos=0; while(sum>r){ sum-=v[pos].first; pos++; } if(sum>=l && sum<=r){ for(int j=pos; j<=i; j++) ans.push_back(v[j].second); return ans; } } } return ans; } /* int main(){ int n, l, r; cin>>n>>l>>r; vector<int> w(n); for(int i=0; i<n; i++){ cin>>w[i]; } vector<int> ans=find_subset(l, r, w); for(auto i:ans) cout<<i<<' '; } */ /* vector<int> find_subset(int l, int r, vector<int> w){ bool cek=true, beda=true; for(int i=1; i<w.size(); i++){ if(w[i]!=w[i-1]) cek=false; if(abs(w[i]-w[i-1])>=2) beda=false; } vector<int> ans; if(cek){ int sum=0; for(int i=0; i<w.size(); i++){ sum+=w[i]; ans.push_back(i); if(sum>=l) break; } if(sum<l || sum>r) ans.clear(); } return ans; else if(beda){ int minx=1000, maxn=-1000; for(int i=0; i<w.size(); i++){ minx=min(minx, w[i]); maxn=max(maxn, w[i]); } vector<int> a, b; for(int i=0; i<w.size(); i++){ if(w[i]==minx) a.push_back(i); else b.push_back(i); } bool cek=false; int sum=0; vector<int> aa, bb; for(int i=0; i<a.size(); i++){ sum+=minx; aa.push_back(a[i]); if(l-sum<=min(b.size(), aa.size())){ break; } if(sum>=l){ break; } } if(sum>r) return ans; if(sum>=l && sum<=r) return aa; if(l-sum<=min(b.size(), aa.size())){ for(int i=0; i<aa.size(); i++) ans.push_back(aa[i]); for(int i=0; i<l-sum; i++) ans.push_back(b[i]); return ans; } for(int i=0; i<b.size(); i++){ sum+=maxn; bb.push_back(b[i]); } } }*/
#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...