結果

問題 No.710 チーム戦
ユーザー treeonetreeone
提出日時 2018-07-26 23:10:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 3,000 ms
コード長 705 bytes
コンパイル時間 1,358 ms
コンパイル使用メモリ 165,192 KB
実行使用メモリ 5,100 KB
最終ジャッジ日時 2023-09-13 18:50:26
合計ジャッジ時間 3,076 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,904 KB
testcase_01 AC 4 ms
4,904 KB
testcase_02 AC 29 ms
4,956 KB
testcase_03 AC 29 ms
4,900 KB
testcase_04 AC 29 ms
4,912 KB
testcase_05 AC 29 ms
4,892 KB
testcase_06 AC 29 ms
4,972 KB
testcase_07 AC 30 ms
4,900 KB
testcase_08 AC 29 ms
4,912 KB
testcase_09 AC 30 ms
4,916 KB
testcase_10 AC 30 ms
4,908 KB
testcase_11 AC 29 ms
4,912 KB
testcase_12 AC 29 ms
4,892 KB
testcase_13 AC 30 ms
4,976 KB
testcase_14 AC 29 ms
4,952 KB
testcase_15 AC 29 ms
4,972 KB
testcase_16 AC 29 ms
4,912 KB
testcase_17 AC 29 ms
5,100 KB
testcase_18 AC 30 ms
4,896 KB
testcase_19 AC 29 ms
4,904 KB
testcase_20 AC 29 ms
4,976 KB
testcase_21 AC 29 ms
4,968 KB
testcase_22 AC 29 ms
4,976 KB
testcase_23 AC 30 ms
4,904 KB
testcase_24 AC 29 ms
5,052 KB
testcase_25 AC 3 ms
4,900 KB
testcase_26 AC 3 ms
4,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
const int INF = 1e15;
const int MAX = 100010;

int a[110], b[110];
int dp[MAX], nxt[MAX];

signed main(){
    int n;
    cin >> n;
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }
    rep(i, 0, MAX) dp[i] = INF;
    dp[0] = 0;
    rep(i, 0, n){
        rep(j, 0, MAX) nxt[j] = INF;
        rep(j, 0, MAX){
            nxt[j] = min(nxt[j], dp[j] + b[i]);
            if(j + a[i] >= MAX) continue;
            nxt[j + a[i]] = min(nxt[j + a[i]], dp[j]);
        }
        swap(dp, nxt);
    }
    int ans = INF;
    rep(i, 0, MAX) ans = min(ans, max(i, dp[i]));
    cout << ans << endl;
}
0