結果

問題 No.710 チーム戦
ユーザー ama_nukoama_nuko
提出日時 2018-07-09 15:02:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 3,000 ms
コード長 1,022 bytes
コンパイル時間 1,253 ms
コンパイル使用メモリ 98,220 KB
実行使用メモリ 83,196 KB
最終ジャッジ日時 2023-09-22 08:41:01
合計ジャッジ時間 3,918 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,948 KB
testcase_01 AC 6 ms
8,544 KB
testcase_02 AC 73 ms
83,044 KB
testcase_03 AC 72 ms
82,988 KB
testcase_04 AC 73 ms
82,948 KB
testcase_05 AC 72 ms
83,028 KB
testcase_06 AC 73 ms
82,964 KB
testcase_07 AC 74 ms
83,036 KB
testcase_08 AC 73 ms
82,944 KB
testcase_09 AC 74 ms
82,972 KB
testcase_10 AC 72 ms
82,980 KB
testcase_11 AC 73 ms
83,044 KB
testcase_12 AC 73 ms
82,940 KB
testcase_13 AC 72 ms
82,924 KB
testcase_14 AC 72 ms
82,968 KB
testcase_15 AC 72 ms
82,988 KB
testcase_16 AC 72 ms
83,032 KB
testcase_17 AC 72 ms
82,972 KB
testcase_18 AC 73 ms
83,036 KB
testcase_19 AC 73 ms
83,140 KB
testcase_20 AC 72 ms
82,948 KB
testcase_21 AC 72 ms
83,196 KB
testcase_22 AC 70 ms
83,028 KB
testcase_23 AC 71 ms
83,032 KB
testcase_24 AC 74 ms
83,000 KB
testcase_25 AC 4 ms
5,328 KB
testcase_26 AC 4 ms
5,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vector<vector<int>> dp(n+1, vector<int>(100001, INF));
    dp[0][0] = 0;
    rep(i, n){
        rep(j, 100000){
            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;
    rep(j, 100001){
        if(ans > max(dp[n][j], j)){
            ans = max(dp[n][j], j);
        }
    }
    cout << ans << endl;

    return 0;
}
0