結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー tentententen
提出日時 2023-03-24 18:55:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,310 bytes
コンパイル時間 3,225 ms
コンパイル使用メモリ 82,932 KB
実行使用メモリ 53,504 KB
最終ジャッジ日時 2023-10-18 20:33:37
合計ジャッジ時間 10,221 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
52,380 KB
testcase_01 AC 56 ms
52,412 KB
testcase_02 AC 55 ms
53,468 KB
testcase_03 AC 56 ms
53,476 KB
testcase_04 AC 55 ms
52,412 KB
testcase_05 AC 55 ms
53,480 KB
testcase_06 AC 55 ms
53,472 KB
testcase_07 AC 56 ms
53,480 KB
testcase_08 AC 55 ms
53,480 KB
testcase_09 AC 56 ms
53,476 KB
testcase_10 AC 56 ms
53,476 KB
testcase_11 WA -
testcase_12 AC 56 ms
53,472 KB
testcase_13 AC 56 ms
53,480 KB
testcase_14 AC 55 ms
53,476 KB
testcase_15 AC 56 ms
53,484 KB
testcase_16 AC 55 ms
53,476 KB
testcase_17 AC 56 ms
52,380 KB
testcase_18 AC 55 ms
52,364 KB
testcase_19 AC 55 ms
52,396 KB
testcase_20 AC 57 ms
53,484 KB
testcase_21 AC 55 ms
53,480 KB
testcase_22 AC 56 ms
53,476 KB
testcase_23 AC 55 ms
53,480 KB
testcase_24 AC 55 ms
53,476 KB
testcase_25 AC 55 ms
53,492 KB
testcase_26 AC 55 ms
53,480 KB
testcase_27 AC 55 ms
53,480 KB
testcase_28 AC 55 ms
53,480 KB
testcase_29 AC 55 ms
53,472 KB
testcase_30 AC 55 ms
53,424 KB
testcase_31 AC 55 ms
53,476 KB
testcase_32 AC 56 ms
53,472 KB
testcase_33 AC 54 ms
53,480 KB
testcase_34 AC 55 ms
53,476 KB
testcase_35 AC 55 ms
53,476 KB
testcase_36 AC 55 ms
53,504 KB
testcase_37 TLE -
testcase_38 -- -
testcase_39 -- -
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 #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] sums = new long[1 << n];
        for (int i = 0; i < n; i++) {
            sums[1 << i] = sc.nextInt();
        }
        for (int i = 1; i < (1 << n); i++) {
            if (sums[i] != 0) {
                continue;
            }
            for (int j = 0; j < n; j++) {
                if ((i & (1 << j)) == 0) {
                    continue;
                }
                sums[i] = sums[i ^ (1 << j)] + sums[1 << j];
                break;
            }
        }
        for (int i = 1; i < (1 << n); i++) {
            int left = (((1 << n) - 1) ^ i);
            for (int j = left; j > 0; j = ((j - 1) & left)) {
                if (sums[i] - sums[j] == k) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0