Submission #561030

# Submission time Handle Problem Language Result Execution time Memory
561030 2022-05-12T07:50:54 Z hoanghq2004 Jelly Flavours (IOI20_jelly) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int n, x, y;
pair <int, int> a[2010];
int dp[2010][100010];
int res;

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(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);
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= x; ++j) {
            dp[i][j] = dp[i - 1][j] + a[i].second;
            if (j >= a[i].first) dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i].first]);
        }
    }
    for (int i = n; i >= 0; --i) {
        int mincost = 1e9, cnt = i;
        for (int j = 0; j <= x; ++j)
            mincost = min(mincost, dp[i][j]);
        if (mincost > y) continue;
        vector <int> s;
        for (int j = i + 1; j <= n; ++j) s.push_back(a[j].second);
        sort(s.begin(), s.end());
        for (auto cost: s) {
            if (mincost + cost <= y) {
                mincost += cost;
                ++cnt;
            }
            else break;
        }
        res = max(res, cnt);
    }
    cout << res << "\n";
}

Compilation message

/usr/bin/ld: /tmp/ccdHBTIF.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cclSrDUE.o:jelly.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccdHBTIF.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