Submission #70776979


Source Code Expand

#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;

int main() {
    int N;
    cin >> N;
    struct Part { int weight, head, body; };
    vector<Part> parts(N);
    for (int i = 0; i < N; i++) {
        int W, H, B;
        cin >> W >> H >> B;
        parts[i] = { W, H, B };
    }
    const int OFF = 500 * 500 + 10;
    const int MX = 2 * OFF + 10;
    vector<ll> dp(MX, 0);
    vector<vector<bool>> visited(N + 1, vector<bool>(MX, 0));
    visited[0][OFF] = true;
    for (int i = 0; i < N; i++) {
        vector<ll> new_dp(MX, 0);
        for (int w = 0; w < MX; w++) {
            if (!visited[i][w]) continue;
            if (w + parts[i].weight < MX) {
                new_dp[w + parts[i].weight] = max(new_dp[w + parts[i].weight], dp[w] + parts[i].body);
                visited[i + 1][w + parts[i].weight] = true;
            }
            if (w - parts[i].weight >= 0) {
                new_dp[w - parts[i].weight] = max(new_dp[w - parts[i].weight], dp[w] + parts[i].head);
                visited[i + 1][w - parts[i].weight] = true;
            }
        }
        dp.swap(new_dp);
    }
    ll best = 0;
    for (int w = OFF; w < MX; w++) {
        best = max(best, dp[w]);
    }
    cout << best << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Robot Customize
User Mitscho
Language C++23 (GCC 15.2.0)
Score 400
Code Size 1311 Byte
Status AC
Exec Time 335 ms
Memory 41836 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 8 ms 11324 KiB
00_sample_01.txt AC 4 ms 11180 KiB
00_sample_02.txt AC 6 ms 11312 KiB
00_sample_03.txt AC 18 ms 12508 KiB
01_random_03.txt AC 332 ms 41760 KiB
01_random_04.txt AC 331 ms 41640 KiB
01_random_05.txt AC 335 ms 41724 KiB
01_random_06.txt AC 330 ms 41760 KiB
01_random_07.txt AC 332 ms 41720 KiB
01_random_08.txt AC 334 ms 41804 KiB
01_random_09.txt AC 334 ms 41760 KiB
01_random_10.txt AC 334 ms 41784 KiB
01_random_11.txt AC 333 ms 41784 KiB
01_random_12.txt AC 252 ms 34732 KiB
01_random_13.txt AC 150 ms 25328 KiB
01_random_14.txt AC 134 ms 24044 KiB
01_random_15.txt AC 188 ms 29248 KiB
01_random_16.txt AC 110 ms 21852 KiB
01_random_17.txt AC 331 ms 41804 KiB
01_random_18.txt AC 332 ms 41720 KiB
01_random_19.txt AC 330 ms 41772 KiB
01_random_20.txt AC 328 ms 41752 KiB
01_random_21.txt AC 329 ms 41784 KiB
01_random_22.txt AC 136 ms 24312 KiB
01_random_23.txt AC 19 ms 12628 KiB
01_random_24.txt AC 9 ms 11576 KiB
01_random_25.txt AC 328 ms 41836 KiB
01_random_26.txt AC 329 ms 41760 KiB
01_random_27.txt AC 328 ms 41720 KiB
01_random_28.txt AC 329 ms 41808 KiB
01_random_29.txt AC 331 ms 41776 KiB
01_random_30.txt AC 327 ms 41532 KiB
01_random_31.txt AC 271 ms 36780 KiB
01_random_32.txt AC 181 ms 28608 KiB
01_random_33.txt AC 4 ms 11320 KiB
01_random_34.txt AC 4 ms 11244 KiB
01_random_35.txt AC 329 ms 41760 KiB
01_random_36.txt AC 325 ms 41760 KiB
01_random_37.txt AC 326 ms 41744 KiB
01_random_38.txt AC 326 ms 41760 KiB
01_random_39.txt AC 325 ms 41772 KiB
01_random_40.txt AC 324 ms 41784 KiB
01_random_41.txt AC 326 ms 41776 KiB
01_random_42.txt AC 326 ms 41752 KiB
01_random_43.txt AC 190 ms 29656 KiB
01_random_44.txt AC 293 ms 39016 KiB
01_random_45.txt AC 262 ms 36268 KiB
01_random_46.txt AC 60 ms 16964 KiB
01_random_47.txt AC 157 ms 26680 KiB
01_random_48.txt AC 296 ms 41828 KiB
01_random_49.txt AC 292 ms 41832 KiB
01_random_50.txt AC 292 ms 41772 KiB
01_random_51.txt AC 39 ms 14608 KiB
01_random_52.txt AC 122 ms 23756 KiB