Submission #465231

#TimeUsernameProblemLanguageResultExecution timeMemory
465231dattranxxxDetecting Molecules (IOI16_molecules)C++11
Compilation error
0 ms0 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; } int main() { int l, u; cin >> n >> l >> u; vector<int> a(n); for (int& x : a) cin >> x; vector<int> res = find_subset(l, u, a); print(res); }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccuYMnf2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccnXdsw1.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status