結果
問題 | No.1457 ツブ消ししとるなHard |
ユーザー | 小野寺健 |
提出日時 | 2021-04-30 17:52:24 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,456 bytes |
コンパイル時間 | 4,620 ms |
コンパイル使用メモリ | 83,776 KB |
実行使用メモリ | 60,684 KB |
最終ジャッジ日時 | 2023-09-25 18:48:50 |
合計ジャッジ時間 | 9,731 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
56,072 KB |
testcase_01 | AC | 126 ms
55,644 KB |
testcase_02 | AC | 130 ms
55,732 KB |
testcase_03 | AC | 130 ms
55,680 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 132 ms
56,276 KB |
testcase_08 | AC | 129 ms
56,368 KB |
testcase_09 | AC | 144 ms
55,900 KB |
testcase_10 | AC | 144 ms
55,956 KB |
testcase_11 | AC | 132 ms
56,180 KB |
testcase_12 | AC | 135 ms
55,892 KB |
testcase_13 | AC | 278 ms
58,340 KB |
testcase_14 | AC | 158 ms
56,380 KB |
testcase_15 | AC | 407 ms
58,684 KB |
testcase_16 | AC | 136 ms
55,864 KB |
testcase_17 | AC | 129 ms
56,064 KB |
testcase_18 | AC | 129 ms
55,900 KB |
testcase_19 | WA | - |
testcase_20 | AC | 129 ms
56,080 KB |
ソースコード
package yukicoder; import java.util.Scanner; import java.util.List; import java.util.ArrayList; import java.util.Collections; public class No1457 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); int X = scan.nextInt(); int Y = scan.nextInt(); int Z = scan.nextInt(); List<Integer> A = new ArrayList<Integer>(); for (int i=0; i < N; i++) { A.add(scan.nextInt()); } scan.close(); Collections.sort(A); int remove = Collections.binarySearch(A, Y + 1); if (remove < 0) { remove = - remove - 1; } int remain = Collections.binarySearch(A, X); if (remain < 0) { remain = - remain - 1; } int remainN = N - remain; if (remainN > M) { System.out.println("Handicapped"); return; } int remainSum = A.subList(remain, N).stream().mapToInt(Integer::intValue).sum(); List<Integer> select = A.subList(remove, remain); int min = remainN > 0 ? 0 : 1; int max = M - remainN; int n = remain - remove; int cnt = 0; for (int i = min; i < 1 << n; i++) { if (Integer.bitCount(i) <= max) { int sum = remainSum; int sumn = remainN; List<Integer> s = new ArrayList<Integer>(); for (int j = 0; j < n; j++) { if (((1 << j) & i) != 0) { sum += select.get(j); sumn++; s.add(select.get(j)); } } if (sum == Z * sumn) { cnt++; } } } System.out.println(cnt); } }