結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー chocoruskchocorusk
提出日時 2021-06-07 00:36:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,457 bytes
コンパイル時間 3,385 ms
コンパイル使用メモリ 191,232 KB
実行使用メモリ 97,884 KB
最終ジャッジ日時 2023-08-15 14:33:20
合計ジャッジ時間 9,538 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
16,188 KB
testcase_01 AC 4 ms
11,632 KB
testcase_02 AC 4 ms
11,632 KB
testcase_03 AC 4 ms
11,552 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
11,596 KB
testcase_07 WA -
testcase_08 AC 5 ms
11,568 KB
testcase_09 AC 5 ms
11,544 KB
testcase_10 AC 5 ms
11,548 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 5 ms
11,592 KB
testcase_13 AC 4 ms
11,640 KB
testcase_14 AC 5 ms
11,616 KB
testcase_15 AC 4 ms
11,736 KB
testcase_16 AC 4 ms
11,636 KB
testcase_17 AC 4 ms
11,560 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 5 ms
11,560 KB
testcase_22 AC 5 ms
11,660 KB
testcase_23 AC 4 ms
11,704 KB
testcase_24 AC 5 ms
11,560 KB
testcase_25 AC 5 ms
11,548 KB
testcase_26 AC 5 ms
11,708 KB
testcase_27 AC 5 ms
11,544 KB
testcase_28 AC 5 ms
11,664 KB
testcase_29 AC 4 ms
11,544 KB
testcase_30 AC 4 ms
11,740 KB
testcase_31 AC 5 ms
11,656 KB
testcase_32 AC 5 ms
11,624 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 4 ms
11,632 KB
testcase_35 AC 5 ms
11,604 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 731 ms
93,444 KB
testcase_38 AC 772 ms
93,628 KB
testcase_39 TLE -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; ll k; cin>>n>>k;
    ll a[22];
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]==k){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    ll s[1<<20]={};
    vector<ll> v[22];
    for(int i=1; i<(1<<n); i++){
        for(int j=0; j<n; j++){
            if(i&(1<<j)) s[i]+=a[j];
        }
        for(int j=0; j<n; j++){
            if(i&(1<<j)) v[j].push_back(s[i]);
        }
    }
    for(int i=0; i<n; i++) sort(v[i].begin(), v[i].end());
    for(int i=1; i<(1<<n); i++){
        for(int j=0; j<n; j++){
            if(i&(1<<j)) continue;
            int t=lower_bound(v[j].begin(), v[j].end(), s[i]-k)-v[j].begin();
            if(t<v[j].size() && v[j][t]==s[i]-k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}
0