Submission #465232

#TimeUsernameProblemLanguageResultExecution timeMemory
465232dattranxxxDetecting Molecules (IOI16_molecules)C++11
9 / 100
1 ms204 KiB
/* * Author : shora */ #include <bits/stdc++.h> #define print(_v) for (auto &_ : _v) {cerr << _ << ' ';} cerr << endl; #include "molecules.h" using namespace std; using ll = long long; const int oo = 1e9; const int N = 1e4, U = 1e4; int dp[U + 1]; int n; vector<int> find_subset(int l, int u, vector<int> a) { n = a.size(); a.insert(a.begin(), 0); sort(a.begin() + 1, a.end()); vector<int> pre(n+2), suf(n+2); for (int i = 1; i <= n; ++i) { pre[i] = pre[i-1] + a[i]; suf[i] = suf[i-1] + a[n-i+1]; } vector<int> res; for (int k = 1; k <= n; ++k) { if (pre[k] <= u && suf[k] >= l) { for (int i = 0; i <= k; ++i) if (l <= pre[i] + suf[k-i] && pre[i] + suf[k-i] <= u) { for (int j = 1; j <= i; ++j) res.push_back(j-1); for (int j = 1; j <= k-i; ++j) res.push_back(n-j); return res; } } } return res; }
#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...