3312021-10-12 21:56:57rmlanBefektetéscpp11Wrong answer 0/4014ms2900 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);
    int b[k+1]={};
    int me=0;
    //for(int i = 1; i <= k;i++) b[i]=INT_MAX;
    for(int i = 0; i < n; i++){
        if(a[i][0]+a[i][2] <= k){

            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){
                    b[j+a[i][0]+a[i][2]] = max(b[j]+a[i][1], b[j+a[i][0]+a[i][2]]);
                    me=max(me, b[j+a[i][0]+a[i][2]]);
                }
            }
            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/02ms1740 KiB
2Wrong answer0/04ms1960 KiB
3Wrong answer0/22ms1864 KiB
4Wrong answer0/22ms1860 KiB
5Wrong answer0/11ms1864 KiB
6Wrong answer0/22ms1880 KiB
7Wrong answer0/21ms1888 KiB
8Wrong answer0/21ms1892 KiB
9Wrong answer0/21ms1888 KiB
10Wrong answer0/21ms1892 KiB
11Wrong answer0/36ms2140 KiB
12Wrong answer0/34ms2168 KiB
13Wrong answer0/34ms2208 KiB
14Wrong answer0/34ms2236 KiB
15Wrong answer0/34ms2260 KiB
16Wrong answer0/46ms2296 KiB
17Wrong answer0/113ms2588 KiB
18Wrong answer0/113ms2652 KiB
19Wrong answer0/113ms2716 KiB
20Wrong answer0/113ms2772 KiB
21Wrong answer0/113ms2832 KiB
22Wrong answer0/114ms2900 KiB