Submission #221125

#TimeUsernameProblemLanguageResultExecution timeMemory
221125joseacazDetecting Molecules (IOI16_molecules)C++17
100 / 100
66 ms4472 KiB
#include "molecules.h" #include <algorithm> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; vi find_subset(int L, int U, vi W) { int N = W.size(); vector<pii> A(N); vi used(N), ans; for(int i = 0; i < N; i++) A[i] = {W[i], i}; sort(A.begin(), A.end()); if(A[0].first > U) return ans; int rpnt = 0; ll sum = 0; for(int lpnt = 0; lpnt < N; lpnt++) { for(; rpnt < N; rpnt++) { if(sum + A[rpnt].first > U) break; used[A[rpnt].second] = 1; sum += A[rpnt].first; } //[lpnt, rpnt) if ( L <= sum ) { for(int i = 0; i < N; i++) if(used[i]) ans.push_back(i); return ans; } sum -= A[lpnt].first; used[A[lpnt].second] = 0; } 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...