9952022-02-20 07:36:41Szin AttilaHálózati biztonság (50)cpp14Time limit exceeded 0/50398ms35552 KiB
#include <bits/stdc++.h>
using namespace std;

inline int read(){
    int res = 0; char ch = getchar();
    while(!isdigit(ch)) ch= getchar();
    while(isdigit(ch)){
        res = (res << 1) + (res << 3) + ch - '0';
        ch = getchar();
    }
    return res;
}

int dp[1002];
int ans = 0;

int main(){
    
    int n,k;
    n = read();
    k = read();  

    vector<pair<int, int>> cikk;

    for(int i = 0; i < n; i++) {
        int t = read(),a = read(),m = read(),mint = read();
        k -= mint * t;
        ans += mint * a;
        m -= mint;
        for(int j = 0; j < m; j++) {
            cikk.push_back({t, a}); 
        }
    }

    for(int i = 0; i < cikk.size(); i++){
        for(int j = k - cikk[i].first; j >= 0; j--){
            dp[j + cikk[i].first] = max(dp[j + cikk[i].first], dp[j] + cikk[i].second);
        }
    }

    cout << dp[k] + ans;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Time limit exceeded0/0365ms852 KiB
2Runtime error0/035ms35096 KiB
3Wrong answer0/21ms1884 KiB
4Time limit exceeded0/2395ms1028 KiB
5Wrong answer0/21ms1964 KiB
6Time limit exceeded0/2391ms1100 KiB
7Time limit exceeded0/2388ms1104 KiB
8Time limit exceeded0/2398ms1176 KiB
9Time limit exceeded0/2397ms1048 KiB
10Runtime error0/24ms5952 KiB
11Time limit exceeded0/2393ms5440 KiB
12Runtime error0/229ms34868 KiB
13Time limit exceeded0/3395ms3348 KiB
14Runtime error0/339ms35412 KiB
15Runtime error0/335ms35352 KiB
16Runtime error0/335ms35504 KiB
17Runtime error0/337ms35552 KiB
18Runtime error0/335ms35492 KiB
19Runtime error0/335ms35512 KiB
20Runtime error0/343ms35528 KiB
21Runtime error0/335ms35544 KiB
22Wrong answer0/31ms2324 KiB