結果

問題 No.710 チーム戦
ユーザー 🍮かんプリン
提出日時 2020-06-09 20:30:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 18 ms / 3,000 ms
コード長 652 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 157,444 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-02 17:14:37
合計ジャッジ時間 2,609 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.09 20:30:27
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    constexpr long long LLINF = 1e18 + 1;
    vector<ll> dp(n*1000+1,LLINF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int a,b;cin >> a >> b;
        for (int j = n*1000; j >= 0; j--) {
            if (j - a >= 0) dp[j] = min(dp[j] + b,dp[j - a]);
            else dp[j] = dp[j] + b;
        }
    }
    ll ans = LLINF;
    for (int i = 0; i <= n*1000; i++) {
        ans = min(ans,max(dp[i],(ll)i));
    }
    cout << ans << endl;
    return 0;
}
0