168422025-05-13 21:42:36algoproJobstown-i milliomoscpp17Wrong answer 0/10026ms760 KiB
// UUID: ac1f26e0-7b93-4458-99c7-ccea738ec30f
#include <bits/stdc++.h>
using namespace std;



int main() {
    #define int long long
    int DP_LEN = 25000;
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;cin >> n >> m;
    vector<int> v(n);
    vector<int> t(n);
    for(int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    int l = min(m, DP_LEN);
    vector<int> dp(l+1);
    dp[0] = 0;
    for(int i = 0; i < l; i++)
    {
        int max_num = 0;
        for(int j = 0; j < n; j++)
        {
            if(i + 1 - t[j] >= 0) max_num = max(max_num, dp[i + 1 -t[j]] + v[j]);
        }
        dp[i+1] = max_num;
    }
    int max_n = 0;
    for(int i = 0; i < l+1; i++)
    {
        max_n = max(dp[i], max_n);
    }
    pair<int, int> max_avg = {v[0], t[0]};
    for(int i = 1; i < n; i++)
    {
        if(v[i] * max_avg.second > t[i] * max_avg.first)
        {
            max_avg.first = v[i];
            max_avg.second = t[i];
        } 
    }   

    if(m <= DP_LEN)
    {
        cout << max_n << "\n";
    }
    // else 
    // {
    //     cout << max_n + ((m-DP_LEN) / max_avg.second) * max_avg.first;
    // }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted1ms316 KiB
subtask20/25
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Wrong answer26ms540 KiB
6Wrong answer26ms604 KiB
7Wrong answer25ms564 KiB
8Wrong answer26ms564 KiB
9Wrong answer26ms564 KiB
10Wrong answer26ms756 KiB
11Wrong answer25ms564 KiB
12Wrong answer25ms564 KiB
13Wrong answer25ms564 KiB
14Wrong answer1ms568 KiB
subtask30/16
15Wrong answer25ms564 KiB
16Wrong answer26ms760 KiB
17Wrong answer26ms564 KiB
18Wrong answer1ms564 KiB
19Wrong answer25ms568 KiB
20Wrong answer25ms756 KiB
21Wrong answer26ms564 KiB
subtask40/59
22Accepted1ms316 KiB
23Accepted1ms508 KiB
24Wrong answer26ms564 KiB
25Wrong answer26ms564 KiB
26Wrong answer26ms564 KiB
27Wrong answer26ms564 KiB
28Wrong answer25ms564 KiB
29Wrong answer26ms564 KiB
30Wrong answer1ms564 KiB
31Wrong answer26ms432 KiB
32Wrong answer25ms576 KiB
33Wrong answer26ms564 KiB