제출 #219187

#제출 시각아이디문제언어결과실행 시간메모리
219187emil_physmathDetecting Molecules (IOI16_molecules)C++17
69 / 100
49 ms6904 KiB
#include "molecules.h" #include <algorithm> #include <iostream> #include <bitset> #include <vector> using namespace std; using llong = long long; const int maxN = 200000; struct Int { llong num; int ind; operator llong&() { return num; } operator const llong&() const { return num; } }; llong pref[maxN]; inline llong Sum(int l, int r) { return pref[r] - (l ? pref[l - 1] : 0); } vector<int> find_subset(int l, int u, vector<int> a) { int m = a.size(); vector<Int> w(m); for (int i = 0; i < m; ++i) w[i] = {a[i], i}; sort(w.begin(), w.end()); for (int i = 0; i < m; ++i) pref[i] = (i ? pref[i - 1] : 0) + w[i]; for (int n = 1; n <= m; ++n) { int mnsum = pref[n - 1], mxsum = Sum(m - n, m - 1); if (mnsum <= u && l <= mxsum) { for (int i = 0; i + n - 1 < m; ++i) if (l <= Sum(i, i + n - 1) && Sum(i, i + n - 1) <= u) { vector<int> res; for (int j = i; j <= i + n - 1; ++j) res.push_back(w[j].ind); return res; } } } return vector<int>(0); }
#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...