結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tentententen
提出日時 2020-08-20 11:02:34
言語 Java21
(openjdk 21)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 805 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 76,784 KB
実行使用メモリ 128,624 KB
最終ジャッジ日時 2024-04-21 05:59:59
合計ジャッジ時間 10,538 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
41,140 KB
testcase_01 AC 118 ms
41,168 KB
testcase_02 AC 122 ms
41,184 KB
testcase_03 AC 122 ms
41,300 KB
testcase_04 AC 121 ms
40,944 KB
testcase_05 AC 117 ms
41,068 KB
testcase_06 AC 122 ms
41,216 KB
testcase_07 AC 116 ms
40,220 KB
testcase_08 AC 421 ms
78,552 KB
testcase_09 AC 134 ms
41,740 KB
testcase_10 AC 668 ms
124,616 KB
testcase_11 AC 369 ms
64,636 KB
testcase_12 AC 331 ms
58,696 KB
testcase_13 AC 362 ms
66,176 KB
testcase_14 AC 391 ms
67,604 KB
testcase_15 AC 528 ms
105,028 KB
testcase_16 AC 290 ms
53,292 KB
testcase_17 AC 297 ms
53,928 KB
testcase_18 AC 506 ms
102,920 KB
testcase_19 AC 349 ms
64,256 KB
testcase_20 AC 130 ms
41,436 KB
testcase_21 AC 457 ms
82,348 KB
testcase_22 AC 132 ms
41,492 KB
testcase_23 AC 104 ms
40,060 KB
testcase_24 AC 114 ms
41,088 KB
testcase_25 MLE -
testcase_26 AC 580 ms
125,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        int[][] dp = new int[n + 1][];
        for (int i = 0; i <= n; i++) {
            dp[i] = new int[i + 1];
        }
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            long x = sc.nextInt();
            for (int j = 0; j < i; j++) {
                dp[i][j] += (int)(dp[i - 1][j] * (x - 1) % MOD);
                dp[i][j] %= MOD;
                dp[i][j + 1] += dp[i - 1][j];
                dp[i][j + 1] %= MOD;
            }
        }
        for (int i = 0; i < q; i++) {
            System.out.println(dp[n][sc.nextInt()]);
        }
    }
} 
0