結果
問題 | No.710 チーム戦 |
ユーザー |
|
提出日時 | 2018-06-29 23:52:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 3,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 1,596 ms |
コンパイル使用メモリ | 168,708 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 00:26:46 |
合計ジャッジ時間 | 2,662 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main() {cin.tie(0);ios::sync_with_stdio(false);int n;cin >> n;vector<int> dp(100005, 100000);dp[0] = 0;int sum = 0;for (int i = 0; i < n; i++) {int a, b;cin >> a >> b;vector<int> dp2(100005, 100000);for (int j = 0; j <= sum; j++) {dp2[j + a] = min(dp2[j + a], dp[j]);dp2[j] = min(dp2[j], dp[j] + b);}sum += a;dp = move(dp2);}int ans = 100000;for (int i = 0; i <= 100000; i++) {ans = min(ans, max(i, dp[i]));}cout << ans << endl;return 0;}