結果
問題 |
No.710 チーム戦
|
ユーザー |
|
提出日時 | 2018-07-13 22:38:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 3,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 1,584 ms |
コンパイル使用メモリ | 168,828 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 05:19:38 |
合計ジャッジ時間 | 3,328 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<double, int> P; typedef pair<int, P> E; #define MOD (1000000007ll) #define l_ength size #define EPS (1e-10) void add_mod(ll &a, ll b){ a += b; a %= MOD; } void mul_mod(ll &a, ll b){ a *= b; a %= MOD; } int main(void){ int n,i,j,a[123],b[123],x[123456],y[123456],ans=INF; cin >> n; fill(x,x+123456,0); for(i=0; i<n; ++i){ cin >> a[i]; cin >> b[i]; } for(i=0; i<n; ++i){ fill(y,y+123456,INF); for(j=0; j<=100000; ++j){ if(j+a[i]<=100000){ y[j+a[i]] = min(x[j],y[j+a[i]]); } y[j] = min(y[j],x[j]+b[i]); } for(j=0; j<=100000; ++j){ x[j] = y[j]; } } for(i=0; i<=100000; ++i){ ans = min(ans,max(i,x[i])); } cout << ans << endl; return 0; }