Submission #70780052


Source Code Expand

#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;
long long dat[250000];

int main()
{
    int n, w = 0;
    scanf("%d", &n);
    pair <int, pair <long long, long long>> arr[n + 100];
    long long val = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        scanf("%d %lld %lld", &arr[i].first, &arr[i].second.first, &arr[i].second.second);
        w += arr[i].first, val += arr[i].second.second;
        arr[i].second.first -= arr[i].second.second;
    }


    memset(dat,-1,sizeof(dat));
    dat[w] = val;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 1 ; j <= w ; j++)
        {
            if(j - 2*arr[i].first < 0)
                continue;
            if(dat[j] == -1)
                continue;
            dat[j - 2*arr[i].first] = max(dat[j - 2*arr[i].first], dat[j] + arr[i].second.first);
        }
    }

    long long ans = val;
    for(int j = w ; j >= 0 ; j--)
    {
        //printf("j = %d -> %lld\n", j, dat[j]);
        ans = max(ans, dat[j]);
    }
    printf("%lld\n", ans);
    return 0;
}

Submission Info

Submission Time
Task D - Robot Customize
User MichaelH
Language C++23 (GCC 15.2.0)
Score 400
Code Size 1099 Byte
Status AC
Exec Time 70 ms
Memory 5916 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 54
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 5812 KiB
00_sample_01.txt AC 2 ms 5808 KiB
00_sample_02.txt AC 2 ms 5788 KiB
00_sample_03.txt AC 2 ms 5720 KiB
01_random_03.txt AC 38 ms 5748 KiB
01_random_04.txt AC 38 ms 5812 KiB
01_random_05.txt AC 39 ms 5716 KiB
01_random_06.txt AC 39 ms 5808 KiB
01_random_07.txt AC 39 ms 5828 KiB
01_random_08.txt AC 40 ms 5916 KiB
01_random_09.txt AC 39 ms 5812 KiB
01_random_10.txt AC 38 ms 5872 KiB
01_random_11.txt AC 39 ms 5812 KiB
01_random_12.txt AC 25 ms 5720 KiB
01_random_13.txt AC 10 ms 5848 KiB
01_random_14.txt AC 8 ms 5748 KiB
01_random_15.txt AC 14 ms 5728 KiB
01_random_16.txt AC 6 ms 5912 KiB
01_random_17.txt AC 38 ms 5848 KiB
01_random_18.txt AC 40 ms 5872 KiB
01_random_19.txt AC 38 ms 5792 KiB
01_random_20.txt AC 36 ms 5808 KiB
01_random_21.txt AC 37 ms 5792 KiB
01_random_22.txt AC 8 ms 5748 KiB
01_random_23.txt AC 2 ms 5748 KiB
01_random_24.txt AC 1 ms 5916 KiB
01_random_25.txt AC 38 ms 5828 KiB
01_random_26.txt AC 39 ms 5860 KiB
01_random_27.txt AC 38 ms 5908 KiB
01_random_28.txt AC 38 ms 5668 KiB
01_random_29.txt AC 39 ms 5792 KiB
01_random_30.txt AC 40 ms 5808 KiB
01_random_31.txt AC 29 ms 5848 KiB
01_random_32.txt AC 15 ms 5828 KiB
01_random_33.txt AC 2 ms 5812 KiB
01_random_34.txt AC 1 ms 5768 KiB
01_random_35.txt AC 37 ms 5720 KiB
01_random_36.txt AC 37 ms 5860 KiB
01_random_37.txt AC 39 ms 5860 KiB
01_random_38.txt AC 37 ms 5912 KiB
01_random_39.txt AC 39 ms 5872 KiB
01_random_40.txt AC 37 ms 5872 KiB
01_random_41.txt AC 38 ms 5860 KiB
01_random_42.txt AC 39 ms 5748 KiB
01_random_43.txt AC 15 ms 5872 KiB
01_random_44.txt AC 33 ms 5916 KiB
01_random_45.txt AC 26 ms 5728 KiB
01_random_46.txt AC 3 ms 5728 KiB
01_random_47.txt AC 11 ms 5812 KiB
01_random_48.txt AC 70 ms 5792 KiB
01_random_49.txt AC 70 ms 5828 KiB
01_random_50.txt AC 70 ms 5728 KiB
01_random_51.txt AC 3 ms 5768 KiB
01_random_52.txt AC 13 ms 5788 KiB