168432025-05-13 21:43:47algoproJobstown-i milliomoscpp17Wrong answer 25/10050ms1012 KiB
// UUID: 354e51ba-5de2-479c-a1d9-5d9781aa6e14
#include <bits/stdc++.h>
using namespace std;



int main() {
    #define int long long
    int DP_LEN = 50000;
    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
subtask225/25
3Accepted1ms316 KiB
4Accepted1ms524 KiB
5Accepted50ms1012 KiB
6Accepted50ms820 KiB
7Accepted50ms820 KiB
8Accepted50ms820 KiB
9Accepted50ms820 KiB
10Accepted50ms836 KiB
11Accepted50ms644 KiB
12Accepted50ms824 KiB
13Accepted50ms820 KiB
14Accepted2ms1004 KiB
subtask30/16
15Wrong answer50ms820 KiB
16Wrong answer50ms820 KiB
17Wrong answer50ms820 KiB
18Wrong answer2ms820 KiB
19Accepted50ms820 KiB
20Accepted50ms824 KiB
21Accepted50ms1012 KiB
subtask40/59
22Accepted1ms508 KiB
23Accepted1ms508 KiB
24Wrong answer50ms820 KiB
25Wrong answer50ms820 KiB
26Wrong answer50ms820 KiB
27Wrong answer50ms756 KiB
28Wrong answer50ms832 KiB
29Wrong answer50ms820 KiB
30Wrong answer2ms564 KiB
31Wrong answer50ms820 KiB
32Wrong answer50ms820 KiB
33Wrong answer50ms820 KiB