Submission #528155

#TimeUsernameProblemLanguageResultExecution timeMemory
528155happypotatoDetecting Molecules (IOI16_molecules)C++17
100 / 100
45 ms5676 KiB
#include "molecules.h" #include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define ff first #define ss second #define pb push_back using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pii> v(n + 1); for (int i = 0; i < n; i++) { v[i + 1] = {w[i], i}; } sort(v.begin() + 1, v.end(), greater<pii>()); int ptr = 0; ll int sum = 0; for (int i = 1; i <= n; i++) { if (sum <= 0) { sum = 0; ptr = i - 1; } while (ptr < n && sum < l) { ptr++; sum += v[ptr].ff; } if (l <= sum && sum <= u) { vector<int> res; for (int j = i; j <= ptr; j++) { res.pb(v[j].ss); } return res; } sum -= v[i].ff; } return {}; }
#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...