結果
問題 | No.710 チーム戦 |
ユーザー |
|
提出日時 | 2021-05-29 15:39:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 3,000 ms |
コード長 | 1,094 bytes |
コンパイル時間 | 2,058 ms |
コンパイル使用メモリ | 195,016 KB |
最終ジャッジ日時 | 2025-01-21 20:30:13 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#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;}