Submission #465191

#TimeUsernameProblemLanguageResultExecution timeMemory
465191dattranxxxDetecting 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; using namespace std; using ll = long long; const int oo = 1e9; const int N = 2e5; int a[N]; map<int, ll> dp[N]; map<int, bool> t[N]; int n; ll call(int i, int l) { if (i == -1) return l <= 0 ? 0 : oo; if (dp[i].count(l)) return dp[i][l]; ll x = call(i-1, l-a[i]) + a[i], y = call(i-1, l); if (x < y) { t[i][l] = 1; return dp[i][l] = x; } else { t[i][l] = 0; return dp[i][l] = y; } } int main() { cin.tie(0)->sync_with_stdio(0); cout.tie(0); int l, u; cin >> n >> l >> u; for (int i = 0; i < n; ++i) cin >> a[i]; call(n-1, l); if (dp[n-1][l] <= u) { n = n-1; while (n) { if (t[n][l]) { cout << n + 1 << ' '; l -= a[n]; } n--; } } return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccNDVRG5.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccA7JsC6.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccNDVRG5.o: in function `main':
grader.cpp:(.text.startup+0x13d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status