結果

問題 No.710 チーム戦
ユーザー snrnsidysnrnsidy
提出日時 2021-05-29 15:39:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 3,000 ms
コード長 1,094 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 196,696 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 12:04:07
合計ジャッジ時間 3,371 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h> 

using namespace std;

int dp[2][100001];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t;

    t = 1;

    while (t--)
    {
        int n, a, b;
        vector <pair<int, int>> v;

        cin >> n;

        for (int i = 0; i < n; i++)
        {
            cin >> a >> b;
            v.push_back(make_pair(a, b));
        }

        dp[1][0] = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j <= 100000; j++)
            {
                dp[0][j] = dp[1][j];
                dp[1][j] = 1e9;
            }
            for (int j = 0; j <= 100000; j++)
            {
                if (j + v[i].first <= 100000)
                {
                    dp[1][j + v[i].first] = min(dp[1][j + v[i].first], dp[0][j]);
                }
                dp[1][j] = min(dp[1][j], dp[0][j] + v[i].second);
            }
        }

        int res = 1e9;
        for (int i = 0; i <= 100000; i++)
        {
            res = min(res, max(i, dp[1][i]));
        }

        cout << res << '\n';

    }

    return 0;
}
0