165072025-05-05 00:02:22algoproJobstown-i milliomoscpp17Wrong answer 25/10079ms1004 KiB
// UUID: 9789475c-de38-43ec-a6f0-c63da216c5ec
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n, limit;
    cin >> n >> limit;

    vector<pair<long long, long long>> jobs(n);

    long long bv = 0, bw = 1;

    for (int i = 0; i < n; i++) {
        cin >> jobs[i].first;
    }
    for (int i = 0; i < n; i++) {
        cin >> jobs[i].second;

        if (1.0 * jobs[i].second / jobs[i].first > 1.0 * bv / bw) {
            bv = jobs[i].second;
            bw = jobs[i].first;
        }
    }
        
    int db = 0;

    if (limit > 50000) {
        db = (limit - 40000) / bw;
    }

    limit = limit - bw * db;

    vector<long long> dp(limit + 1, 0);
    dp[0] = db * bw;

    for (int i = 0; i <= limit; i++) {
        for (const auto& j : jobs) {
            if (j.first <= i) {
                dp[i] = max(dp[i], dp[i - j.first] + j.second);
            }

        }
    }

    cout << dp[limit];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted1ms316 KiB
subtask225/25
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Accepted78ms628 KiB
6Accepted78ms820 KiB
7Accepted78ms820 KiB
8Accepted78ms676 KiB
9Accepted78ms820 KiB
10Accepted78ms820 KiB
11Accepted78ms820 KiB
12Accepted79ms824 KiB
13Accepted79ms1004 KiB
14Accepted2ms564 KiB
subtask30/16
15Wrong answer64ms564 KiB
16Wrong answer63ms748 KiB
17Wrong answer64ms564 KiB
18Wrong answer1ms756 KiB
19Wrong answer63ms564 KiB
20Wrong answer63ms564 KiB
21Wrong answer63ms780 KiB
subtask40/59
22Accepted1ms316 KiB
23Accepted1ms316 KiB
24Wrong answer63ms564 KiB
25Wrong answer63ms564 KiB
26Wrong answer63ms564 KiB
27Wrong answer64ms564 KiB
28Wrong answer63ms756 KiB
29Wrong answer64ms564 KiB
30Wrong answer1ms564 KiB
31Wrong answer63ms564 KiB
32Wrong answer63ms564 KiB
33Wrong answer63ms756 KiB