結果

問題 No.710 チーム戦
ユーザー 梧桐
提出日時 2025-10-23 12:18:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 3,000 ms
コード長 575 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 61,524 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-23 12:18:42
合計ジャッジ時間 2,120 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d%d", &a[i], &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>

using namespace std;

const int N = 110, M = 100010, INF = 0x3f3f3f3f;

int n, a[N], b[N], bsum, dp[M], ans;

int main() {
    scanf("%d", &n);

    bsum = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        bsum += b[i];
    }

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

    ans = INF;
    for (int i = 1; i < M; ++i) {
        ans = min(ans, max(i, bsum - dp[i]));
    }
    printf("%d\n", ans);

    return 0;
}
0