結果

問題 No.710 チーム戦
ユーザー kyawashellkyawashell
提出日時 2018-06-30 01:18:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 3,000 ms
コード長 587 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 71,588 KB
実行使用メモリ 4,412 KB
最終ジャッジ日時 2023-09-13 16:02:58
合計ジャッジ時間 1,904 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 11 ms
4,376 KB
testcase_03 AC 11 ms
4,376 KB
testcase_04 AC 11 ms
4,376 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 11 ms
4,376 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 11 ms
4,384 KB
testcase_09 AC 11 ms
4,376 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 11 ms
4,412 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 11 ms
4,380 KB
testcase_17 AC 11 ms
4,380 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 12 ms
4,380 KB
testcase_20 AC 11 ms
4,388 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 11 ms
4,376 KB
testcase_24 AC 11 ms
4,384 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

ll n,a[101],b[101],dp[1000000];
int main() {
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

    dp[0] = 0;

    for(int i = 1;i <= n;i++) {
        for(int j = 100000;j >= a[i - 1];j--) {
            dp[j] = max(dp[j],dp[j - a[i - 1]] + b[i - 1]);
        }
    }

    ll sum = 0;
    for(int i = 0;i < n;i++)sum += b[i];

    ll ans = 1e18;

    for(int i = 0;i <= 100000;i++) {
        ans = min(ans,max((ll)i,sum - dp[i]));
    }
    cout << ans << endl;
}
0