제출 #536289

#제출 시각아이디문제언어결과실행 시간메모리
536289terrasphereDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms468 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=0; bool possible=true; while(left<=right) { if(sum<l) { if(right>=n) { possible=false; break; } sum+=v[right].first; arr[v[right].second]=true; right++; } else if(sum>u) { sum-=v[left].first; arr[v[left].second]=false; left++; } else break; } if(!possible) return std::vector<int>(0); for(int i=1;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...