結果

問題 No.710 チーム戦
ユーザー kenjihkenjih
提出日時 2018-10-02 22:47:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 3,000 ms
コード長 723 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 59,920 KB
実行使用メモリ 43,056 KB
最終ジャッジ日時 2023-08-02 14:28:18
合計ジャッジ時間 2,700 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
42,812 KB
testcase_01 AC 15 ms
42,808 KB
testcase_02 AC 30 ms
42,720 KB
testcase_03 AC 32 ms
42,880 KB
testcase_04 AC 30 ms
42,804 KB
testcase_05 AC 30 ms
42,736 KB
testcase_06 AC 31 ms
42,744 KB
testcase_07 AC 31 ms
43,056 KB
testcase_08 AC 31 ms
42,792 KB
testcase_09 AC 30 ms
42,852 KB
testcase_10 AC 30 ms
42,944 KB
testcase_11 AC 30 ms
42,848 KB
testcase_12 AC 30 ms
42,992 KB
testcase_13 AC 31 ms
42,792 KB
testcase_14 AC 31 ms
42,720 KB
testcase_15 AC 30 ms
42,848 KB
testcase_16 AC 30 ms
42,808 KB
testcase_17 AC 30 ms
42,828 KB
testcase_18 AC 30 ms
42,796 KB
testcase_19 AC 30 ms
43,048 KB
testcase_20 AC 30 ms
42,952 KB
testcase_21 AC 30 ms
42,876 KB
testcase_22 AC 26 ms
42,740 KB
testcase_23 AC 27 ms
42,892 KB
testcase_24 AC 33 ms
42,736 KB
testcase_25 AC 14 ms
42,852 KB
testcase_26 AC 14 ms
42,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 1<<28;
int n;
int a[100], b[100];
int dp[101][100001];

int main(int argc, char *argv[])
{
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  
  for (int i = 0; i < 101; i++)
    fill(dp[i], dp[i] + 100001, INF);

  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 100001; j++) {
      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 ret = INF;
  for (int i = 0; i < 100001; i++)
    if (dp[n][i] != INF)
      ret = min(ret, max(i, dp[n][i]));

  cout << ret << endl;
  
  return 0;
}
0