165052025-05-04 23:54:33algoproJobstown-i milliomoscpp17Wrong answer 0/1007ms508 KiB
// UUID: d0ede61b-0dfe-429c-a148-f5daacc04b88
#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 > 5000) {
        db = (limit - 4000) / bw;
    }

    limit = limit - bw * db;

    vector<long long> dp(limit + 1, 0);

    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] + db * bw;
}

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


    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms508 KiB
2Accepted1ms316 KiB
subtask20/25
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Wrong answer7ms464 KiB
6Wrong answer7ms316 KiB
7Wrong answer7ms468 KiB
8Wrong answer7ms316 KiB
9Wrong answer7ms508 KiB
10Wrong answer7ms460 KiB
11Wrong answer7ms316 KiB
12Wrong answer7ms460 KiB
13Wrong answer7ms508 KiB
14Wrong answer1ms500 KiB
subtask30/16
15Wrong answer7ms316 KiB
16Wrong answer7ms508 KiB
17Wrong answer7ms316 KiB
18Wrong answer1ms496 KiB
19Wrong answer7ms464 KiB
20Wrong answer7ms460 KiB
21Wrong answer7ms316 KiB
subtask40/59
22Accepted1ms316 KiB
23Accepted1ms316 KiB
24Wrong answer7ms316 KiB
25Wrong answer7ms464 KiB
26Wrong answer7ms500 KiB
27Wrong answer7ms316 KiB
28Wrong answer7ms500 KiB
29Wrong answer7ms316 KiB
30Wrong answer1ms316 KiB
31Wrong answer7ms464 KiB
32Wrong answer7ms316 KiB
33Wrong answer7ms464 KiB