結果

問題 No.710 チーム戦
ユーザー たこしたこし
提出日時 2018-09-28 19:05:58
言語 C++17
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 45 ms / 3,000 ms
コード長 1,210 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 199,068 KB
実行使用メモリ 90,160 KB
最終ジャッジ日時 2023-08-02 10:34:56
合計ジャッジ時間 4,669 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
89,936 KB
testcase_01 AC 29 ms
89,888 KB
testcase_02 AC 43 ms
89,940 KB
testcase_03 AC 42 ms
89,888 KB
testcase_04 AC 42 ms
89,980 KB
testcase_05 AC 43 ms
89,908 KB
testcase_06 AC 44 ms
89,944 KB
testcase_07 AC 43 ms
89,892 KB
testcase_08 AC 43 ms
89,896 KB
testcase_09 AC 43 ms
89,900 KB
testcase_10 AC 43 ms
89,940 KB
testcase_11 AC 43 ms
89,936 KB
testcase_12 AC 42 ms
89,892 KB
testcase_13 AC 42 ms
89,896 KB
testcase_14 AC 44 ms
89,912 KB
testcase_15 AC 43 ms
89,956 KB
testcase_16 AC 43 ms
89,900 KB
testcase_17 AC 42 ms
89,960 KB
testcase_18 AC 43 ms
89,864 KB
testcase_19 AC 42 ms
89,884 KB
testcase_20 AC 42 ms
90,124 KB
testcase_21 AC 43 ms
89,948 KB
testcase_22 AC 41 ms
89,888 KB
testcase_23 AC 42 ms
89,920 KB
testcase_24 AC 45 ms
90,160 KB
testcase_25 AC 27 ms
90,148 KB
testcase_26 AC 28 ms
89,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <cstdio>
#include <string>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

const int MAX_N = 105;
const int MAX_A = 1005;

int N;
int A[MAX_N], B[MAX_N];

int dp[MAX_N][MAX_N*MAX_A];

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    for(int i = 0; i < MAX_N; i++) {
        for(int j = 0; j < MAX_N * MAX_A; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < MAX_N * MAX_A; j++) {
            if(dp[i][j] == INF) {
                continue;
            }
            dp[i+1][j + A[i]] = min(dp[i+1][j + A[i]], dp[i][j]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j] + B[i]);
        }
    }

    int ans = INF;
    for(int i = 0; i < MAX_N * MAX_A; i++) {
        if(dp[N][i] == INF) continue;
        ans = min(ans, max(i, dp[N][i]));
    }

    cout << ans << endl;

    return 0;
}
0