제출 #864412

#제출 시각아이디문제언어결과실행 시간메모리
864412dpsaveslivesDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms544 KiB
#include "molecules.h" #include <bits/stdc++.h> #define ll long long #define f first #define s second using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ vector<pair<ll,int>> sorted; int n = (int)(w.size()); for(int i = 0;i<n;++i) sorted.push_back({w[i],i}); sort(sorted.begin(),sorted.end()); ll sum = w[0]; int j = 0, st = -1, ed = -1; vector<int> ans; for(int i = 0;i<n;++i){ while(j+1 < n && sum+sorted[j+1].f < l){ sum += sorted[j+1].f; ++j; } if(j+1 < n && sum < l){ sum += sorted[j+1].f; ++j; } if(l <= sum && sum <= u){ st = i; ed = j; break; } sum -= sorted[i].f; } if(st != -1){ vector<int> ans; for(int i = st;i <= ed;++i){ ans.push_back(sorted[i].s); } return ans; } 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...