提出 #70798052


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAXN = 5e2+5;
int n, w[MAXN], h[MAXN], b[MAXN], dp[MAXN*MAXN], qian[MAXN];
// dp[j]代表身体重量为j时的最大幸福度

signed main()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> w[i] >> h[i] >> b[i], qian[i] = qian[i-1]+w[i];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for (int i=1; i<=n; i++)
    {
        for (int j=qian[i]; j>=0; j--)
        {
            // 第i个零件给头
            if (dp[j]>=0) dp[j]+=h[i];
            // 第i个零件给身体
            if (j-w[i]>=0 && dp[j-w[i]]>=0) dp[j] = max(dp[j], dp[j-w[i]]+b[i]); 
        }
    }   
    int ans = 0;
    for (int i=1; i<=qian[n]; i++)
    {
        if (qian[n]-i<=i) ans = max(ans, dp[i]);
    }
    cout << ans;

    return 0;
}

提出情報

提出日時
問題 D - Robot Customize
ユーザ nxzwcry
言語 C++23 (GCC 15.2.0)
得点 400
コード長 843 Byte
結果 AC
実行時間 58 ms
メモリ 5752 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 54
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 2 ms 5640 KiB
00_sample_01.txt AC 2 ms 5636 KiB
00_sample_02.txt AC 2 ms 5624 KiB
00_sample_03.txt AC 2 ms 5412 KiB
01_random_03.txt AC 26 ms 5624 KiB
01_random_04.txt AC 26 ms 5636 KiB
01_random_05.txt AC 27 ms 5456 KiB
01_random_06.txt AC 26 ms 5468 KiB
01_random_07.txt AC 27 ms 5436 KiB
01_random_08.txt AC 27 ms 5624 KiB
01_random_09.txt AC 27 ms 5712 KiB
01_random_10.txt AC 27 ms 5608 KiB
01_random_11.txt AC 27 ms 5720 KiB
01_random_12.txt AC 18 ms 5668 KiB
01_random_13.txt AC 8 ms 5628 KiB
01_random_14.txt AC 6 ms 5456 KiB
01_random_15.txt AC 11 ms 5608 KiB
01_random_16.txt AC 5 ms 5752 KiB
01_random_17.txt AC 27 ms 5608 KiB
01_random_18.txt AC 27 ms 5636 KiB
01_random_19.txt AC 27 ms 5464 KiB
01_random_20.txt AC 26 ms 5712 KiB
01_random_21.txt AC 27 ms 5608 KiB
01_random_22.txt AC 7 ms 5752 KiB
01_random_23.txt AC 2 ms 5412 KiB
01_random_24.txt AC 2 ms 5636 KiB
01_random_25.txt AC 26 ms 5640 KiB
01_random_26.txt AC 28 ms 5640 KiB
01_random_27.txt AC 27 ms 5720 KiB
01_random_28.txt AC 27 ms 5556 KiB
01_random_29.txt AC 28 ms 5636 KiB
01_random_30.txt AC 27 ms 5612 KiB
01_random_31.txt AC 20 ms 5468 KiB
01_random_32.txt AC 11 ms 5752 KiB
01_random_33.txt AC 2 ms 5752 KiB
01_random_34.txt AC 2 ms 5668 KiB
01_random_35.txt AC 27 ms 5624 KiB
01_random_36.txt AC 26 ms 5688 KiB
01_random_37.txt AC 27 ms 5412 KiB
01_random_38.txt AC 26 ms 5468 KiB
01_random_39.txt AC 28 ms 5668 KiB
01_random_40.txt AC 26 ms 5412 KiB
01_random_41.txt AC 27 ms 5624 KiB
01_random_42.txt AC 27 ms 5640 KiB
01_random_43.txt AC 11 ms 5712 KiB
01_random_44.txt AC 23 ms 5636 KiB
01_random_45.txt AC 19 ms 5688 KiB
01_random_46.txt AC 3 ms 5648 KiB
01_random_47.txt AC 9 ms 5720 KiB
01_random_48.txt AC 58 ms 5752 KiB
01_random_49.txt AC 58 ms 5412 KiB
01_random_50.txt AC 58 ms 5648 KiB
01_random_51.txt AC 3 ms 5752 KiB
01_random_52.txt AC 11 ms 5624 KiB