結果

問題 No.2055 12x34...
ユーザー 👑 kakel-sankakel-san
提出日時 2022-08-28 21:21:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 105,984 KB
実行使用メモリ 46,440 KB
最終ジャッジ日時 2024-04-23 17:40:17
合計ジャッジ時間 8,090 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
19,328 KB
testcase_01 AC 25 ms
19,328 KB
testcase_02 AC 47 ms
21,740 KB
testcase_03 AC 69 ms
24,576 KB
testcase_04 AC 87 ms
27,264 KB
testcase_05 AC 100 ms
32,512 KB
testcase_06 AC 86 ms
27,264 KB
testcase_07 AC 73 ms
24,960 KB
testcase_08 AC 64 ms
23,424 KB
testcase_09 AC 105 ms
32,896 KB
testcase_10 AC 109 ms
33,280 KB
testcase_11 AC 58 ms
23,296 KB
testcase_12 AC 103 ms
39,168 KB
testcase_13 AC 155 ms
46,440 KB
testcase_14 AC 74 ms
34,048 KB
testcase_15 AC 76 ms
34,176 KB
testcase_16 AC 161 ms
46,280 KB
testcase_17 AC 81 ms
31,360 KB
testcase_18 AC 125 ms
40,704 KB
testcase_19 AC 50 ms
24,448 KB
testcase_20 AC 39 ms
20,844 KB
testcase_21 AC 51 ms
24,576 KB
testcase_22 AC 151 ms
43,008 KB
testcase_23 AC 141 ms
42,496 KB
testcase_24 AC 147 ms
44,976 KB
testcase_25 AC 147 ms
42,880 KB
testcase_26 AC 138 ms
41,984 KB
testcase_27 AC 147 ms
45,396 KB
testcase_28 AC 152 ms
45,528 KB
testcase_29 AC 152 ms
45,216 KB
testcase_30 AC 142 ms
42,624 KB
testcase_31 AC 144 ms
42,368 KB
testcase_32 AC 151 ms
45,220 KB
testcase_33 AC 118 ms
34,560 KB
testcase_34 AC 120 ms
34,944 KB
testcase_35 AC 123 ms
34,688 KB
testcase_36 AC 117 ms
34,944 KB
testcase_37 AC 118 ms
34,560 KB
testcase_38 AC 120 ms
34,816 KB
testcase_39 AC 120 ms
34,816 KB
testcase_40 AC 120 ms
34,816 KB
testcase_41 AC 117 ms
34,944 KB
testcase_42 AC 118 ms
34,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var n = NN;
        var a = NList;
        var mod = 998_244_353;
        var ncnt = new Dictionary<int, long>();
        var ecnt = new Dictionary<int, long>();
        for (var i = 0; i < n; ++i)
        {
            var add = 0L;
            if (ncnt.ContainsKey(a[i] - 1))
            {
                add = (ncnt[a[i] - 1] + ecnt[a[i] - 1]) % mod;
            }
            if (ncnt.ContainsKey(a[i]))
            {
                ncnt[a[i]] += 1;
                ecnt[a[i]] = (ecnt[a[i]] + add) % mod;
            }
            else
            {
                ncnt[a[i]] = 1;
                ecnt[a[i]] = add;
            }
        }
        var res = 0L;
        foreach (var kv in ecnt) res = (res + kv.Value) % mod;
        WriteLine(res);
    }
}
0