Submission #70783142


Source Code Expand

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define int ll

const int N = 501;

int dp[N][N * N];

int w[N], h[N], b[N];

int n;
int total;

int calc(int ind, int body){
    if(ind == n){
        int head = total - body;
        if(head > body){
            return -1e12;
        }
        return 0;
    }
    if(dp[ind][body] != -1){
        return dp[ind][body];
    }
    return dp[ind][body] = max(calc(ind + 1, body + w[ind]) + b[ind], calc(ind + 1, body) + h[ind]);
}


int32_t main(){
    FAST
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < n; i++){
        cin >> w[i] >> h[i] >> b[i];
        total += w[i];
    }
    cout << calc(0, 0);
    return 0;
}

Submission Info

Submission Time
Task D - Robot Customize
User Basilhijaz
Language C++23 (Clang 21.1.0)
Score 400
Code Size 1136 Byte
Status AC
Exec Time 755 ms
Memory 985624 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 474 ms 985308 KiB
00_sample_01.txt AC 450 ms 985304 KiB
00_sample_02.txt AC 448 ms 985624 KiB
00_sample_03.txt AC 452 ms 985428 KiB
01_random_03.txt AC 726 ms 985588 KiB
01_random_04.txt AC 729 ms 985588 KiB
01_random_05.txt AC 755 ms 985600 KiB
01_random_06.txt AC 737 ms 985440 KiB
01_random_07.txt AC 716 ms 985612 KiB
01_random_08.txt AC 739 ms 985612 KiB
01_random_09.txt AC 731 ms 985612 KiB
01_random_10.txt AC 751 ms 985612 KiB
01_random_11.txt AC 750 ms 985532 KiB
01_random_12.txt AC 617 ms 985596 KiB
01_random_13.txt AC 506 ms 985440 KiB
01_random_14.txt AC 509 ms 985612 KiB
01_random_15.txt AC 561 ms 985588 KiB
01_random_16.txt AC 477 ms 985624 KiB
01_random_17.txt AC 728 ms 985440 KiB
01_random_18.txt AC 714 ms 985600 KiB
01_random_19.txt AC 750 ms 985612 KiB
01_random_20.txt AC 737 ms 985600 KiB
01_random_21.txt AC 709 ms 985612 KiB
01_random_22.txt AC 513 ms 985412 KiB
01_random_23.txt AC 449 ms 985484 KiB
01_random_24.txt AC 447 ms 985472 KiB
01_random_25.txt AC 696 ms 985404 KiB
01_random_26.txt AC 714 ms 985412 KiB
01_random_27.txt AC 707 ms 985616 KiB
01_random_28.txt AC 711 ms 985556 KiB
01_random_29.txt AC 709 ms 985588 KiB
01_random_30.txt AC 718 ms 985472 KiB
01_random_31.txt AC 635 ms 985404 KiB
01_random_32.txt AC 540 ms 985396 KiB
01_random_33.txt AC 451 ms 985588 KiB
01_random_34.txt AC 447 ms 985460 KiB
01_random_35.txt AC 754 ms 985436 KiB
01_random_36.txt AC 728 ms 985588 KiB
01_random_37.txt AC 731 ms 985624 KiB
01_random_38.txt AC 752 ms 985556 KiB
01_random_39.txt AC 724 ms 985600 KiB
01_random_40.txt AC 712 ms 985436 KiB
01_random_41.txt AC 710 ms 985548 KiB
01_random_42.txt AC 715 ms 985448 KiB
01_random_43.txt AC 546 ms 985612 KiB
01_random_44.txt AC 678 ms 985412 KiB
01_random_45.txt AC 627 ms 985496 KiB
01_random_46.txt AC 458 ms 985484 KiB
01_random_47.txt AC 528 ms 985556 KiB
01_random_48.txt AC 452 ms 985612 KiB
01_random_49.txt AC 452 ms 985588 KiB
01_random_50.txt AC 448 ms 985368 KiB
01_random_51.txt AC 446 ms 985460 KiB
01_random_52.txt AC 446 ms 985412 KiB