제출 #974381

#제출 시각아이디문제언어결과실행 시간메모리
974381tamir1Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms348 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans={}; int n=w.size(),sum=0,m=0,k,p,x=0; for(int i=0;i<n;i++) sum+=w[i]; if(sum<l) return ans; sort(w.begin(),w.end()); sum=0; for(int i=0;i<n;i++){ if(sum+w[i]>u) break; sum+=w[i]; m=i+1; } if(m==0) return {}; k=n-1; p=0; while(sum<l){ if(k<m || p==m) break; x++; sum+=w[k]; sum-=w[p]; k--; p++; } if(sum<l) return {}; for(int i=x;i<m;i++) ans.push_back(w[i]); for(int i=n-1;i>=n-x;i--) ans.push_back(w[i]); 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...