結果

問題 No.1163 I want to be a high achiever
ユーザー hiro71687khiro71687k
提出日時 2023-03-27 19:14:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,189 bytes
コンパイル時間 4,622 ms
コンパイル使用メモリ 263,852 KB
実行使用メモリ 59,648 KB
最終ジャッジ日時 2023-10-19 18:12:49
合計ジャッジ時間 8,328 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 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>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.141592653589793;
ll inf=1444999994;
ll mod=1000000007;
int main(){
    ll n,x;
    cin >>  n >> x;
    vector<ll>a(n),b(n);
    ll sum=0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    vector<vector<ll>>dp(sum+1,vector<ll>(n,inf));
    dp[sum][0]=0;
    dp[sum-a[0]][1]=b[0];
    for (ll i = 1; i < n; i++)
    {
        for (ll j = i; j >=0; j--)
        {
            for (ll k = sum; k >=0; k--)
            {
                if (dp[k][j]==inf)
                {
                    continue;
                }
                dp[k-a[i]][j+1]=min(dp[k-a[i]][j+1],dp[k][j]+b[i]);
            }
        }
    }
    ll ans=inf;
    for (ll i = 0; i <= sum; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            if ((n-j)*x<=i)
            {
                ans=min(ans,dp[i][j]);
            }
        }
    }
    if (ans==inf)
    {
        cout << -1 << endl;
        return 0;
    }else{
        cout << ans << endl;
    }
    
}
0