제출 #536383

#제출 시각아이디문제언어결과실행 시간메모리
536383terrasphereDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms592 KiB
#include "molecules.h" #include <bits/stdc++.h> std::vector<int> find_subset(int l, int u, std::vector<int> w) { std::vector<std::pair<int,int>> v; int n=w.size(); for(int i=0;i<n;i++) v.push_back({w[i],i}); std::sort(v.begin(),v.end()); std::vector<int> answer; bool arr[222222]; int left=0,right=0; long long sum=v[0].first; arr[0]=true; bool possible=true; while(1) { if(sum<l) { right++; if(right>=n) { possible=false; break; } sum+=v[right].first; arr[v[right].second]=true; } else if(sum>u) { sum-=v[left].first; arr[v[left].second]=false; left++; } else break; if(left>=right) { possible=false; break; } } if(!possible) return std::vector<int>(0); for(int i=0;i<n;i++) if(arr[i]) answer.push_back(i); return answer; }
#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...