結果
| 問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-08-20 10:56:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 801 bytes |
| 記録 | |
| コンパイル時間 | 2,218 ms |
| コンパイル使用メモリ | 77,840 KB |
| 実行使用メモリ | 370,584 KB |
| 最終ジャッジ日時 | 2024-10-13 04:23:40 |
| 合計ジャッジ時間 | 11,279 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 MLE * 10 |
ソースコード
import java.util.*;
public class Main {
static final int MOD = 998244353;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
long[][] dp = new long[n + 1][n + 1];
dp[0][0] = 1;
for (int i = 1; i <= n; i++) {
int x = sc.nextInt();
for (int j = 0; j < i; j++) {
dp[i][j] += dp[i - 1][j] * (x - 1) % MOD;
dp[i][j] %= MOD;
dp[i][j + 1] += dp[i - 1][j];
dp[i][j + 1] %= MOD;
}
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < q; i++) {
sb.append(dp[n][sc.nextInt()]).append("\n");
}
System.out.print(sb);
}
}
tenten