제출 #974795

#제출 시각아이디문제언어결과실행 시간메모리
974795d4xnDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms408 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define int long long vector<signed> sb; std::vector<signed> find_subset(signed l, signed u, std::vector<signed> w) { int n = w.size(); sort(w.begin(), w.end()); int sum = 0; int R = -1; while (R+1 < n && sum + w[R+1] <= u) { sum += w[++R]; sb.push_back(R); } if (l <= sum) return sb; int L = n; while (min(R, L-1) >= 0 && sum - w[R] + w[L-1] <= u) { sum += w[--L] - w[R--]; sb.pop_back(); } for (int i = n-1; i >= L; i--) { sb.push_back(i); } if (sum < l || u < sum) sb.clear(); return sb; }
#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...