結果
| 問題 |
No.1457 ツブ消ししとるなHard
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-04-13 09:49:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,121 bytes |
| コンパイル時間 | 2,487 ms |
| コンパイル使用メモリ | 78,780 KB |
| 実行使用メモリ | 51,732 KB |
| 最終ジャッジ日時 | 2024-06-29 04:06:54 |
| 合計ジャッジ時間 | 4,663 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 WA * 4 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;
int[][] dp = new int[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