Submission #641792

#TimeUsernameProblemLanguageResultExecution timeMemory
641792dattranxxxJelly Flavours (IOI20_jelly)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e3 + 5, M = 1e4 + 5; using ii = pair<int, int>; ii a[N], dp[N][M]; ii best(ii& u, ii& v) { if (u.first == v.first) return u.second < v.second ? u : v; return u.first > v.first ? u : v; } int n, X, Y; int main() { cin.tie(0)->sync_with_stdio(0); cout.tie(0); cin >> n >> X >> Y; for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; sort(a + 1, a + n + 1, [&](ii& u, ii& v) { return u.second < v.second; }); for (int x = 0; x <= X; ++x) dp[0][x] = {0, 0}; for (int i = 1; i <= n; ++i) for (int x = 0; x <= X; ++x) { dp[i][x] = dp[i-1][x]; if (x >= a[i].first) { auto p = dp[i-1][x-a[i].first]; p.first++; dp[i][x] = best(dp[i][x], p); } if (dp[i-1][x].second + a[i].second <= Y) { auto p = dp[i-1][x]; p.first++; p.second += a[i].second; dp[i][x] = best(dp[i][x], p); } } cout << dp[n][X].first; return 0; }

Compilation message (stderr)

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