Submission #70779984


Source Code Expand

#include <bits/stdc++.h>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define int long long
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int, int> PI;
typedef pair<int, pair<int, int>> PII;
static const int INF = 1010000000000000017LL;
static const double eps = 1e-12;
static const double pi = 3.14159265358979323846;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};
static const int ddx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
static const int ddy[8] = {0, 0, 1, -1, 1, -1, 1, -1};

template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int MAX_W = 250000;

int N;

signed main() {
    cin >> N;
    vector<int> W(N), H(N), B(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> W[i] >> H[i] >> B[i];
        sum += W[i];
    }
    vector<vector<int>> dp(N, vector<int>(MAX_W + 1, 0));
    dp[0][W[0]] = H[0];
    dp[0][0] = B[0];
    for (int i = 0; i < N - 1; ++i) {
        for (int j = 0; j <= MAX_W; ++j) {
            // 頭につける
            if (j + W[i + 1] <= MAX_W) {
                chmax(dp[i + 1][j + W[i + 1]], dp[i][j] + H[i + 1]);
            }
            chmax(dp[i + 1][j], dp[i][j] + B[i + 1]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= MAX_W; ++i) {
        int b_w = sum - i;
        if (i <= b_w) {
            chmax(ans, dp[N - 1][i]);
        }
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Robot Customize
User tsuyosshi
Language C++23 (GCC 15.2.0)
Score 400
Code Size 1755 Byte
Status AC
Exec Time 636 ms
Memory 983288 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 5 ms 11072 KiB
00_sample_01.txt AC 3 ms 7208 KiB
00_sample_02.txt AC 4 ms 9136 KiB
00_sample_03.txt AC 25 ms 44336 KiB
01_random_03.txt AC 621 ms 983232 KiB
01_random_04.txt AC 635 ms 983232 KiB
01_random_05.txt AC 636 ms 983160 KiB
01_random_06.txt AC 588 ms 983232 KiB
01_random_07.txt AC 585 ms 983228 KiB
01_random_08.txt AC 583 ms 983228 KiB
01_random_09.txt AC 582 ms 983196 KiB
01_random_10.txt AC 582 ms 983216 KiB
01_random_11.txt AC 588 ms 983168 KiB
01_random_12.txt AC 454 ms 758320 KiB
01_random_13.txt AC 278 ms 461004 KiB
01_random_14.txt AC 253 ms 416072 KiB
01_random_15.txt AC 352 ms 582320 KiB
01_random_16.txt AC 208 ms 343616 KiB
01_random_17.txt AC 583 ms 983228 KiB
01_random_18.txt AC 583 ms 983192 KiB
01_random_19.txt AC 583 ms 983244 KiB
01_random_20.txt AC 578 ms 983288 KiB
01_random_21.txt AC 577 ms 983168 KiB
01_random_22.txt AC 250 ms 425776 KiB
01_random_23.txt AC 22 ms 50224 KiB
01_random_24.txt AC 6 ms 15096 KiB
01_random_25.txt AC 574 ms 983156 KiB
01_random_26.txt AC 575 ms 983288 KiB
01_random_27.txt AC 573 ms 983200 KiB
01_random_28.txt AC 575 ms 983212 KiB
01_random_29.txt AC 574 ms 983232 KiB
01_random_30.txt AC 570 ms 975352 KiB
01_random_31.txt AC 482 ms 822712 KiB
01_random_32.txt AC 328 ms 562736 KiB
01_random_33.txt AC 3 ms 7232 KiB
01_random_34.txt AC 2 ms 7212 KiB
01_random_35.txt AC 575 ms 983212 KiB
01_random_36.txt AC 574 ms 983228 KiB
01_random_37.txt AC 583 ms 983244 KiB
01_random_38.txt AC 581 ms 983288 KiB
01_random_39.txt AC 582 ms 983220 KiB
01_random_40.txt AC 581 ms 983216 KiB
01_random_41.txt AC 581 ms 983220 KiB
01_random_42.txt AC 580 ms 983160 KiB
01_random_43.txt AC 357 ms 596016 KiB
01_random_44.txt AC 533 ms 895280 KiB
01_random_45.txt AC 480 ms 811200 KiB
01_random_46.txt AC 105 ms 189116 KiB
01_random_47.txt AC 295 ms 498176 KiB
01_random_48.txt AC 580 ms 983168 KiB
01_random_49.txt AC 580 ms 983228 KiB
01_random_50.txt AC 581 ms 983096 KiB
01_random_51.txt AC 66 ms 116804 KiB
01_random_52.txt AC 241 ms 404248 KiB