Submission #824093

#TimeUsernameProblemLanguageResultExecution timeMemory
824093SoulKnightDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms312 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ln '\n' const int N = 2e5 + 5; ll pfx[N], idx[N], n; vector<ll> vec; vector<int> ans; vector<int> find_subset(int l, int u, std::vector<int> w) { n = w.size(); vec.resize(n+1); iota(idx, idx+n, 0); sort(idx, idx+n, [&](int x, int y){return w[x] < w[y];}); for (int i = 1; i <= n; i++) vec[i] = w[idx[i-1]]; for (int i = 1; i <= n; i++) pfx[i] = pfx[i-1] + vec[i]; for (int k = 1; k <= n; k++){ ll res = pfx[k]; ll lf = 1, rt = n; while (res < l && lf < rt){ res -= vec[lf++]; res += vec[rt--]; } if (l <= res && res <= u) { for (int j = 0; j < k; j++){ ans.push_back(idx[lf]); lf++; } return ans; } } 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...