結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tentententen
提出日時 2020-08-20 11:00:55
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 725 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 74,676 KB
実行使用メモリ 232,012 KB
最終ジャッジ日時 2024-04-21 05:57:46
合計ジャッジ時間 12,320 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,380 KB
testcase_01 AC 130 ms
41,296 KB
testcase_02 AC 128 ms
41,236 KB
testcase_03 AC 116 ms
40,176 KB
testcase_04 AC 129 ms
41,292 KB
testcase_05 AC 132 ms
41,416 KB
testcase_06 AC 130 ms
41,160 KB
testcase_07 AC 132 ms
41,504 KB
testcase_08 AC 494 ms
104,704 KB
testcase_09 AC 146 ms
41,516 KB
testcase_10 MLE -
testcase_11 AC 417 ms
80,916 KB
testcase_12 AC 409 ms
69,800 KB
testcase_13 AC 438 ms
78,868 KB
testcase_14 AC 429 ms
80,108 KB
testcase_15 MLE -
testcase_16 AC 344 ms
58,948 KB
testcase_17 AC 347 ms
61,552 KB
testcase_18 MLE -
testcase_19 AC 425 ms
78,696 KB
testcase_20 AC 149 ms
41,820 KB
testcase_21 AC 567 ms
124,748 KB
testcase_22 AC 152 ms
44,828 KB
testcase_23 AC 129 ms
41,688 KB
testcase_24 AC 118 ms
40,276 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

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][n + 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