結果
問題 | No.710 チーム戦 |
ユーザー |
|
提出日時 | 2020-06-27 10:45:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 85 ms / 3,000 ms |
コード長 | 768 bytes |
コンパイル時間 | 1,151 ms |
コンパイル使用メモリ | 85,908 KB |
最終ジャッジ日時 | 2025-01-11 12:39:41 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <map>#include <queue>#include <cstdio>#include <set>using namespace std;typedef long long int ll;int dp[101][100010];int main(){cin.tie(nullptr);ios::sync_with_stdio(false);int n; cin >> n;vector<int> a(n),b(n);int sum=0;for(int i=0;i<n;i++){cin >> a[i] >> b[i];sum+=b[i];}int res=1e9;for(int i=0;i<n;i++){for(int j=0;j<=100000;j++){if(j+a[i]<=100000){dp[i+1][j+a[i]]=max(dp[i+1][j+a[i]],dp[i][j]+b[i]);}dp[i+1][j]=max(dp[i+1][j],dp[i][j]);}}for(int i=0;i<=100000;i++){res=min(res,max(i,sum-dp[n][i]));}cout << res << endl;}