結果

問題 No.1163 I want to be a high achiever
ユーザー t98slidert98slider
提出日時 2023-02-25 19:44:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 840 bytes
コンパイル時間 1,649 ms
コンパイル使用メモリ 170,028 KB
実行使用メモリ 204,480 KB
最終ジャッジ日時 2023-10-11 16:18:16
合計ジャッジ時間 6,743 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N), B(N);
    for(auto &v: A)cin >> v;
    for(auto &v: B)cin >> v;
    ll s = accumulate(B.begin(), B.end(), 0ll);
    vector<vector<ll>> dp(N + 1, vector<ll>(100 * N + 1, -(1ll << 60)));
    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = i; j >= 0; j--){
            for(int k = j * 100; k >= 0; k--){
                dp[j + 1][k + A[i]] = max(dp[j + 1][k + A[i]], dp[j][k] + B[i]);
            }
        }
    }
    ll ans = 1ll << 60;
    for(int i = 1; i <= N; i++){
        for(int j = 100 * i; j >= 0; j--){
            if(X * i <= j) ans = min(ans, s - dp[i][j]);
        }
    }
    if(ans >> 60) ans = -1;
    cout << ans << '\n';
}
0