結果
問題 | No.710 チーム戦 |
ユーザー | ei1333333 |
提出日時 | 2018-06-29 22:34:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 3,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 1,676 ms |
コンパイル使用メモリ | 195,300 KB |
最終ジャッジ日時 | 2025-01-06 11:41:25 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int INF = 1 << 30; int main() { int N; cin >> N; vector< int > dp(100001, INF); dp[0] = 0; for(int i = 0; i < N; i++) { int x, y; cin >> x >> y; vector< int > dp2(100001, INF); for(int j = 100000; j >= 0; j--) { if(j - x >= 0) dp2[j] = min(dp2[j], dp[j - x]); dp2[j] = min(dp2[j], dp[j] + y); } dp.swap(dp2); } int ret = INF; for(int i = 0; i < 100001; i++) { ret = min(ret, max(dp[i], i)); } cout << ret << endl; }