168442025-05-13 21:44:10algoproJobstown-i milliomoscpp17Wrong answer 25/100492ms4332 KiB
// UUID: 5b4e6c9e-fe05-42cc-8111-df41e47a98f2
#include <bits/stdc++.h>
using namespace std;



int main() {
    #define int long long
    int DP_LEN = 500000;
    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
1Accepted1ms508 KiB
2Accepted1ms316 KiB
subtask225/25
3Accepted1ms316 KiB
4Accepted1ms420 KiB
5Accepted50ms820 KiB
6Accepted50ms1004 KiB
7Accepted50ms820 KiB
8Accepted50ms824 KiB
9Accepted50ms824 KiB
10Accepted50ms1012 KiB
11Accepted50ms820 KiB
12Accepted50ms820 KiB
13Accepted50ms1004 KiB
14Accepted2ms820 KiB
subtask30/16
15Wrong answer490ms4332 KiB
16Wrong answer490ms4148 KiB
17Wrong answer490ms4148 KiB
18Wrong answer8ms4148 KiB
19Accepted490ms4148 KiB
20Accepted490ms4152 KiB
21Accepted490ms4148 KiB
subtask40/59
22Accepted1ms500 KiB
23Accepted1ms500 KiB
24Wrong answer492ms4148 KiB
25Wrong answer492ms4332 KiB
26Wrong answer490ms4148 KiB
27Wrong answer490ms4148 KiB
28Wrong answer490ms4148 KiB
29Wrong answer490ms4148 KiB
30Wrong answer8ms4148 KiB
31Wrong answer490ms4152 KiB
32Wrong answer490ms4148 KiB
33Wrong answer490ms4148 KiB