Submission #62053559


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define pb push_back
#define int long long
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using ll = long long;
using vi = vector<int>;
using ar2 = array<int,2>;
using ar3 = array<int,3>;

const int mxN = (int)5e3+10;
const int INF = (int)1e9;
const ll LINF = (ll)2e18;
const int MOD = (int)1e9+7;

int n, X;
vector<ar2> v[3];
int dp[3][mxN];
string s[mxN];

void solve(){
    cin >> n >> X;
    for(int i = 0; i < n; i++){
        int xd, a, c; 
        cin >> xd >> a >> c;
        v[xd-1].pb({a,c});
    }
    for(int _ = 0; _ < 3; _++){
        for(int i = 1; i <= sz(v[_]); i++)
            for(int j = 5000; j>=v[_][i-1][1]; j--)
                dp[_][j] = max(dp[_][j], dp[_][j-v[_][i-1][1]]+v[_][i-1][0]);
        for(int i = 1; i <= 5000; i++) 
            dp[_][i]=max(dp[_][i],dp[_][i-1]);
    }
    int ans = 0;
    for(int i = 0; i <= X; i++){
        for(int j = 0; i+j <= X; j++){
            int rem = X-(i+j);
            ans = max(ans, min({dp[0][i],dp[1][j],dp[2][rem]}));
        }
    }
    cout << ans << "\n";
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1; //cin >> t;
    while(t--) solve();
}

Submission Info

Submission Time
Task E - Vitamin Balance
User dan4life
Language C++ 23 (gcc 12.2)
Score 450
Code Size 1505 Byte
Status AC
Exec Time 30 ms
Memory 4040 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 2
AC × 58
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt, random_40.txt, random_41.txt, random_42.txt, random_43.txt, random_44.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3832 KiB
example_01.txt AC 12 ms 3760 KiB
hand_00.txt AC 1 ms 3764 KiB
hand_01.txt AC 22 ms 3836 KiB
hand_02.txt AC 12 ms 3776 KiB
hand_03.txt AC 22 ms 3960 KiB
hand_04.txt AC 12 ms 3644 KiB
hand_05.txt AC 1 ms 3760 KiB
hand_06.txt AC 30 ms 3776 KiB
hand_07.txt AC 13 ms 4040 KiB
hand_08.txt AC 12 ms 3772 KiB
hand_09.txt AC 1 ms 3752 KiB
hand_10.txt AC 30 ms 3800 KiB
random_00.txt AC 11 ms 3780 KiB
random_01.txt AC 12 ms 3748 KiB
random_02.txt AC 12 ms 3832 KiB
random_03.txt AC 12 ms 3792 KiB
random_04.txt AC 11 ms 3788 KiB
random_05.txt AC 12 ms 3788 KiB
random_06.txt AC 4 ms 3772 KiB
random_07.txt AC 12 ms 3780 KiB
random_08.txt AC 12 ms 3780 KiB
random_09.txt AC 7 ms 3796 KiB
random_10.txt AC 12 ms 3788 KiB
random_11.txt AC 12 ms 3740 KiB
random_12.txt AC 15 ms 3848 KiB
random_13.txt AC 15 ms 3880 KiB
random_14.txt AC 17 ms 3896 KiB
random_15.txt AC 12 ms 3752 KiB
random_16.txt AC 12 ms 3784 KiB
random_17.txt AC 12 ms 3772 KiB
random_18.txt AC 2 ms 3644 KiB
random_19.txt AC 11 ms 3824 KiB
random_20.txt AC 12 ms 3780 KiB
random_21.txt AC 13 ms 3764 KiB
random_22.txt AC 11 ms 3724 KiB
random_23.txt AC 5 ms 3716 KiB
random_24.txt AC 8 ms 3744 KiB
random_25.txt AC 12 ms 3764 KiB
random_26.txt AC 14 ms 3824 KiB
random_27.txt AC 20 ms 3836 KiB
random_28.txt AC 22 ms 3712 KiB
random_29.txt AC 15 ms 3808 KiB
random_30.txt AC 11 ms 3780 KiB
random_31.txt AC 11 ms 3716 KiB
random_32.txt AC 11 ms 3776 KiB
random_33.txt AC 10 ms 3760 KiB
random_34.txt AC 2 ms 3832 KiB
random_35.txt AC 4 ms 3772 KiB
random_36.txt AC 3 ms 3788 KiB
random_37.txt AC 12 ms 3764 KiB
random_38.txt AC 11 ms 3792 KiB
random_39.txt AC 3 ms 3856 KiB
random_40.txt AC 13 ms 3788 KiB
random_41.txt AC 5 ms 3784 KiB
random_42.txt AC 22 ms 3884 KiB
random_43.txt AC 27 ms 3880 KiB
random_44.txt AC 16 ms 3900 KiB