結果

問題 No.1163 I want to be a high achiever
ユーザー rogi52rogi52
提出日時 2022-10-22 14:17:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 201,116 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 08:54:07
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,X; cin >> N >> X;
    vector<int> A(N), B(N);
    int BASE = 100;
    rep(i,N) cin >> A[i], A[i] -= X, A[i] += BASE;
    rep(i,N) cin >> B[i];
    int BSUM = accumulate(B.begin(), B.end(), 0);

    int MAX = 200 * 500;
    vector<int> dp(MAX + 1, 1e9);
    dp[0] = 0;
    rep(i,N) {
        vector<int> nt = dp;
        for(int s = 0; s <= MAX; s++) {
            if(s + A[i] <= MAX)
                nt[s + A[i]] = min(nt[s + A[i]], dp[s]);
            if(s + BASE <= MAX)
                nt[s + BASE] = min(nt[s + BASE], dp[s] + B[i]);
        }
        swap(nt, dp);
    }

    int ans = 1e9;
    for(int s = BASE * N; s <= MAX; s++) ans = min(ans, dp[s]);
    cout << (ans == ll(1e18) ? -1 : ans) << endl;
}
0