Submission #562837

#TimeUsernameProblemLanguageResultExecution timeMemory
562837imtiyazrasool92Detecting Molecules (IOI16_molecules)C++17
100 / 100
61 ms5584 KiB
#include "molecules.h" #include<algorithm> #include<array> #include<iostream> using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<array<int, 2>> A((int)w.size()); for (int i = 0; i < (int)w.size(); i++) { A[i][0] = w[i]; A[i][1] = i; } sort(A.begin(), A.end()); vector<int> result; int64_t sum = 0; int L = -1, R = 0; while (R < (int)A.size()) { sum += A[R][0]; while (sum > u) { sum -= A[++L][0]; } if (sum >= l) { for (int i = L + 1; i <= R; i++) { result.push_back(A[i][1]); } cerr << sum << '\n'; break; } R++; } return result; }
#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...