結果

問題 No.1538 引きこもりさんは引き算が得意。
コンテスト
ユーザー hiro71687k
提出日時 2023-03-30 20:07:07
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 697 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,109 ms
コンパイル使用メモリ 271,416 KB
実行使用メモリ 1,306,624 KB
最終ジャッジ日時 2026-06-30 02:38:02
合計ジャッジ時間 14,689 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 4 MLE * 2 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=9999999999999999;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    map<ll,ll>memo;
    vector<map<ll,ll>>dp(n+1);
    for (ll i = 0; i < n; i++)
    {
        dp[i+1]=dp[i];
        dp[i+1][a[i]]=1;
        for(auto v:dp[i]){
            dp[i+1][v.first-a[i]]=1;
            dp[i+1][a[i]-v.first]=1;
        }
    }
    if (dp[n][k]>=1)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}
0