結果

問題 No.710 チーム戦
ユーザー merom686
提出日時 2018-06-30 12:36:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 3,000 ms
コード長 609 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-01 00:53:41
合計ジャッジ時間 1,559 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int dp[100001];

int main() {
    int n;
    cin >> n;

    int s = 0, k = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        s += b;
        for (int j = k; j >= 0; j--) {
            dp[j + a] = max(dp[j + a], dp[j] + b);
        }
        k += a;
    }

    int r = 1 << 30;
    for (int j = 0; j <= k; j++) {
        r = min(r, max(j, s - dp[j]));
    }

    cout << r << endl;

    return 0;
}
0