3332021-10-13 19:29:54rmlanBefektetéscpp11Wrong answer 0/4037ms2888 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define ll long long
#define tc int _TC_; cin >> _TC_; while(_TC_--)
using namespace std;
bool comp(vector<int> a, vector<int> b){
    return a[2] < b[2];
}
int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int> > a(n);
    for(int i = 0; i < n;i++){
        a[i].resize(3);
        int p,v,t;
        cin >> p >> v >> t;
        a[i][0]=p;
        a[i][1]=v;
        a[i][2]=t;
    }
    sort(a.begin(), a.end(), comp);
    vector<int> b(k+1), b2(k+1);
    int me=0;
    for(int i = 1; i <= k;i++){
        b[i]=0;
        b2[i]=0;
    }
    for(int i = 0; i < n; i++){
        if(a[i][0]+a[i][2] <= k){
            b2=b;
            for(int j = 1; j <= k-a[i][0]-a[i][2]; j++){
                if(b[j] != 0 && j+a[i][0]+a[i][2] <= k){
                    b2[j+a[i][0]+a[i][2]] = max(b[j]+a[i][1], b[j+a[i][0]+a[i][2]]);
                    me=max(me, b2[j+a[i][0]+a[i][2]]);
                    //cout << me << endl;
                }
            }
            b=b2;
            b[a[i][0]]=max(b[a[i][0]], a[i][1]);
            me=max(me, b[a[i][0]]);

        }
    }
    cout << me << endl;
}

SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/02ms1752 KiB
2Wrong answer0/04ms1916 KiB
3Wrong answer0/21ms1852 KiB
4Wrong answer0/21ms1864 KiB
5Wrong answer0/11ms1860 KiB
6Wrong answer0/22ms1884 KiB
7Wrong answer0/22ms1884 KiB
8Wrong answer0/22ms1892 KiB
9Wrong answer0/21ms1884 KiB
10Wrong answer0/22ms1892 KiB
11Wrong answer0/39ms2136 KiB
12Wrong answer0/39ms2180 KiB
13Wrong answer0/310ms2208 KiB
14Wrong answer0/310ms2236 KiB
15Wrong answer0/39ms2268 KiB
16Wrong answer0/49ms2296 KiB
17Wrong answer0/137ms2576 KiB
18Wrong answer0/128ms2640 KiB
19Wrong answer0/128ms2700 KiB
20Wrong answer0/135ms2768 KiB
21Wrong answer0/129ms2824 KiB
22Wrong answer0/137ms2888 KiB