結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tentententen
提出日時 2020-08-20 10:56:04
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 801 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 373,912 KB
最終ジャッジ日時 2024-04-21 05:50:59
合計ジャッジ時間 11,752 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
40,896 KB
testcase_01 AC 113 ms
41,128 KB
testcase_02 AC 120 ms
40,968 KB
testcase_03 AC 101 ms
41,136 KB
testcase_04 AC 120 ms
41,052 KB
testcase_05 AC 107 ms
40,832 KB
testcase_06 AC 125 ms
40,932 KB
testcase_07 AC 122 ms
41,024 KB
testcase_08 MLE -
testcase_09 AC 136 ms
41,308 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 341 ms
103,140 KB
testcase_13 MLE -
testcase_14 AC 387 ms
123,564 KB
testcase_15 MLE -
testcase_16 AC 302 ms
75,536 KB
testcase_17 AC 308 ms
77,000 KB
testcase_18 MLE -
testcase_19 AC 351 ms
103,312 KB
testcase_20 AC 133 ms
41,460 KB
testcase_21 MLE -
testcase_22 AC 132 ms
41,024 KB
testcase_23 AC 117 ms
41,076 KB
testcase_24 AC 108 ms
40,992 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();
        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);
    }
} 
0