제출 #661337

#제출 시각아이디문제언어결과실행 시간메모리
661337GoldLightDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; int pos; std::vector<int> find_subset(int l, int r, std::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); break; } } else{ 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); break; } } } 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...