結果
問題 | No.710 チーム戦 |
ユーザー |
|
提出日時 | 2020-08-09 00:39:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 3,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 810 ms |
コンパイル使用メモリ | 73,832 KB |
最終ジャッジ日時 | 2025-01-12 19:10:45 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <iostream>#include <vector>constexpr int INF = 1 << 30;void solve() {int n;std::cin >> n;std::vector<int> dp(1, 0);while (n--) {int a, b;std::cin >> a >> b;int m = dp.size() - 1;dp.resize(m + a + 1, INF);for (int i = m + a; i >= 0; --i) {dp[i] += b;if (i >= a) dp[i] = std::min(dp[i], dp[i - a]);}}int ans = INF;for (int t = 0; t < (int)dp.size(); ++t) {ans = std::min(ans, std::max(t, dp[t]));}std::cout << ans << "\n";}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}