제출 #465233

#제출 시각아이디문제언어결과실행 시간메모리
465233dattranxxxDetecting 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+1), suf(n+1); 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 (l <= suf[k] && pre[k] <= u) { for (int i = 0; i <= k; ++i) if (l <= pre[i] + suf[k-i] && pre[i] + suf[k-i] <= u) { int sum = 0; for (int j = 1; j <= i; ++j) res.push_back(j-1), sum += a[j]; for (int j = 1; j <= k-i; ++j) res.push_back(n-j), sum += a[n-j+1]; assert(l <= sum && sum <= u); 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...