제출 #717747

#제출 시각아이디문제언어결과실행 시간메모리
717747ToxtaqDetecting Molecules (IOI16_molecules)C++17
100 / 100
54 ms5556 KiB
#include<bits/stdc++.h> #include "molecules.h" /// https://codeforces.com/blog/entry/52464 /// https://oj.uz/submission/715687 using namespace std; vector<int> find_subset(int l, int r, vector<int>w){ int n = w.size(); vector<pair<int, int>>sorted(n); for(int i = 0;i < n;++i){ sorted[i] = {w[i], i}; } sort(sorted.begin(), sorted.end()); vector<int>ans; int left = 0, right = 0; long long sum = 0; while(left <= right && right < n){ sum += sorted[right].first; while(sum > r){ sum -= sorted[left].first; left++; } if(sum >= l && sum <= r){ for(int i = left;i <= right;++i){ ans.push_back(sorted[i].second); } return ans; } right++; } return ans; } // //int main() //{ // int l, r, n; // cin >> l >> r >> n; // vector<int>v(n); // for(int i = 0;i < n;++i)cin >> v[i]; // vector<int>ans = find_subset(l, r, v); // for(int i : ans)cout << 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...