結果
| 問題 | 
                            No.1457 ツブ消ししとるなHard
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tenten
                         | 
                    
| 提出日時 | 2021-04-13 15:38:58 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,123 bytes | 
| コンパイル時間 | 2,103 ms | 
| コンパイル使用メモリ | 78,296 KB | 
| 実行使用メモリ | 51,864 KB | 
| 最終ジャッジ日時 | 2024-06-29 20:30:17 | 
| 合計ジャッジ時間 | 3,938 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 RE * 1 | 
ソースコード
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        int count = 0;
        int total = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a >= x) {
                count++;
                total += a;
            } else if (a > y) {
                list.add(a);
            }
        }
        if (count == m) {
            if (m * z == total) {
                System.out.println(1);
            } else {
                System.out.println(0);
            }
            return;
        } else if (count > m) {
            System.out.println("Handicapped");
            return;
        }
        m -= count;
        long[][] dp = new long[m + 1][list.size() * 50 + 1];
        dp[0][0] = 1;
        for (int i = 0; i < list.size(); i++) {
            int a = list.get(i);
            for (int j = Math.min(i, m - 1); j >= 0 ; j--) {
                for (int k = j * 50; k >= 0; k--) {
                    dp[j + 1][k + a] += dp[j][k];
                }
            }
        }
        long ans = 0;
        for (int i = 1; i <= m; i++) {
            if ((i + count) * z - total >= 0)
            ans += dp[i][(i + count) * z - total];
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
            
            
            
        
            
tenten