Submission #62083348


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9')
        f = (c == '-') ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9')
        x = x * 10 + c - 48, c = getchar();
    return f * x;
}
struct node {
    int v, a, c;
} a[10010];
int n, x;
int f[4][5010];
int dp[4][5010];
int maxx = 0;
void check() {
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= x; j++) {
            if(j >= a[i].c)
                f[a[i].v][j] = max(dp[a[i].v][j], dp[a[i].v][j - a[i].c] + a[i].a);
            else
                f[a[i].v][j] = dp[a[i].v][j];
        }
        for(int j = 1; j <= x; j++)
            dp[a[i].v][j] = f[a[i].v][j];
    }
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= x; j++)
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
    for(int i = 1; i <= x; i++)
        for(int j = 1; j <= x - i; j++) {
            maxx = max(maxx, min(dp[1][i], min(dp[2][j], dp[3][x - i - j])));
        }
}
signed main() {
    n = read(), x = read();
    for(int i = 1; i <= n; i++) {
        a[i] = {read(), read(), read()};
    }
    check();
    cout << maxx;
}

Submission Info

Submission Time
Task E - Vitamin Balance
User hbx
Language C++ 20 (gcc 12.2)
Score 450
Code Size 1243 Byte
Status AC
Exec Time 35 ms
Memory 3800 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 3584 KiB
example_01.txt AC 12 ms 3596 KiB
hand_00.txt AC 1 ms 3484 KiB
hand_01.txt AC 17 ms 3596 KiB
hand_02.txt AC 14 ms 3588 KiB
hand_03.txt AC 34 ms 3668 KiB
hand_04.txt AC 12 ms 3628 KiB
hand_05.txt AC 1 ms 3520 KiB
hand_06.txt AC 32 ms 3632 KiB
hand_07.txt AC 35 ms 3612 KiB
hand_08.txt AC 12 ms 3548 KiB
hand_09.txt AC 1 ms 3388 KiB
hand_10.txt AC 32 ms 3748 KiB
random_00.txt AC 11 ms 3628 KiB
random_01.txt AC 12 ms 3572 KiB
random_02.txt AC 12 ms 3564 KiB
random_03.txt AC 13 ms 3612 KiB
random_04.txt AC 11 ms 3564 KiB
random_05.txt AC 12 ms 3612 KiB
random_06.txt AC 4 ms 3448 KiB
random_07.txt AC 13 ms 3612 KiB
random_08.txt AC 12 ms 3768 KiB
random_09.txt AC 7 ms 3584 KiB
random_10.txt AC 14 ms 3576 KiB
random_11.txt AC 15 ms 3576 KiB
random_12.txt AC 13 ms 3584 KiB
random_13.txt AC 11 ms 3484 KiB
random_14.txt AC 24 ms 3660 KiB
random_15.txt AC 12 ms 3612 KiB
random_16.txt AC 13 ms 3572 KiB
random_17.txt AC 13 ms 3560 KiB
random_18.txt AC 2 ms 3488 KiB
random_19.txt AC 11 ms 3544 KiB
random_20.txt AC 13 ms 3580 KiB
random_21.txt AC 14 ms 3612 KiB
random_22.txt AC 12 ms 3608 KiB
random_23.txt AC 5 ms 3584 KiB
random_24.txt AC 8 ms 3592 KiB
random_25.txt AC 12 ms 3460 KiB
random_26.txt AC 14 ms 3568 KiB
random_27.txt AC 22 ms 3520 KiB
random_28.txt AC 22 ms 3800 KiB
random_29.txt AC 14 ms 3596 KiB
random_30.txt AC 11 ms 3688 KiB
random_31.txt AC 11 ms 3584 KiB
random_32.txt AC 11 ms 3632 KiB
random_33.txt AC 11 ms 3560 KiB
random_34.txt AC 2 ms 3548 KiB
random_35.txt AC 4 ms 3524 KiB
random_36.txt AC 3 ms 3520 KiB
random_37.txt AC 12 ms 3568 KiB
random_38.txt AC 12 ms 3560 KiB
random_39.txt AC 2 ms 3496 KiB
random_40.txt AC 13 ms 3564 KiB
random_41.txt AC 5 ms 3584 KiB
random_42.txt AC 22 ms 3532 KiB
random_43.txt AC 29 ms 3536 KiB
random_44.txt AC 3 ms 3548 KiB