結果

問題 No.710 チーム戦
ユーザー たこしたこし
提出日時 2018-09-28 19:05:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 3,000 ms
コード長 1,210 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 195,636 KB
実行使用メモリ 90,280 KB
最終ジャッジ日時 2024-04-20 09:58:50
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
90,200 KB
testcase_01 AC 28 ms
90,136 KB
testcase_02 AC 47 ms
90,216 KB
testcase_03 AC 47 ms
90,280 KB
testcase_04 AC 47 ms
90,184 KB
testcase_05 AC 46 ms
90,192 KB
testcase_06 AC 46 ms
90,152 KB
testcase_07 AC 46 ms
90,148 KB
testcase_08 AC 46 ms
90,116 KB
testcase_09 AC 46 ms
90,204 KB
testcase_10 AC 45 ms
90,020 KB
testcase_11 AC 47 ms
90,148 KB
testcase_12 AC 47 ms
90,140 KB
testcase_13 AC 47 ms
90,180 KB
testcase_14 AC 46 ms
90,160 KB
testcase_15 AC 48 ms
90,024 KB
testcase_16 AC 47 ms
90,116 KB
testcase_17 AC 46 ms
90,224 KB
testcase_18 AC 47 ms
89,988 KB
testcase_19 AC 46 ms
89,980 KB
testcase_20 AC 46 ms
90,072 KB
testcase_21 AC 46 ms
90,108 KB
testcase_22 AC 45 ms
89,988 KB
testcase_23 AC 45 ms
89,996 KB
testcase_24 AC 49 ms
90,200 KB
testcase_25 AC 27 ms
90,184 KB
testcase_26 AC 27 ms
90,112 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