Submission #423842

#TimeUsernameProblemLanguageResultExecution timeMemory
423842kwongwengDetecting Molecules (IOI16_molecules)C++17
100 / 100
93 ms6716 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long long ll; #define FOR(i, a, b) for (int i = a; i < b; i++) #define pb push_back #define fi first #define se second vi find_subset(int l, int u, vi w) { vi ans; int n = w.size(); vector<pair<ll, int>> W(n); FOR(i, 0, n) W[i] = {w[i], i}; sort(W.begin(), W.end()); vector<ll> sum(n+1); ll L = l; ll R = u; FOR(i, 1, n+1){ sum[i] = sum[i-1] + W[i-1].fi; } FOR(i, 1, n+1){ if (sum[i] > R || sum[n] - sum[n-i] < L) continue; FOR(j, i, n+1){ ll len = sum[j] - sum[j-i]; if (len >= L && len <= R){ FOR(k, j-i, j) ans.pb(W[k].se); 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...