結果

問題 No.617 Nafmo、買い出しに行く
ユーザー KKT89
提出日時 2020-07-12 16:59:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 108,200 KB
最終ジャッジ日時 2025-01-11 20:02:52
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 8 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

bool dp[2002000];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int mx=0;
    dp[0]=1;
    for(int i=k;i>=0;i--){
        for(int j=0;j<n;j++){
            if(dp[i]&&i+a[j]<=k){
                dp[i+a[j]]=1;
                mx=max(mx,i+a[j]);
            }
        }
    }
    cout << mx << endl;
}
0