結果
| 問題 | 
                            No.1457 ツブ消ししとるなHard
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-04-30 17:52:24 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,456 bytes | 
| コンパイル時間 | 4,018 ms | 
| コンパイル使用メモリ | 90,380 KB | 
| 実行使用メモリ | 45,996 KB | 
| 最終ジャッジ日時 | 2024-07-18 14:55:28 | 
| 合計ジャッジ時間 | 8,944 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 13 WA * 4 | 
ソースコード
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);
	}
}