結果

問題 No.2055 12x34...
ユーザー デカブツデカブツ
提出日時 2022-08-21 14:13:23
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,466 bytes
コンパイル時間 7,203 ms
コンパイル使用メモリ 171,760 KB
実行使用メモリ 206,440 KB
最終ジャッジ日時 2024-04-18 12:58:52
合計ジャッジ時間 14,137 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
29,568 KB
testcase_01 AC 48 ms
29,696 KB
testcase_02 AC 80 ms
34,048 KB
testcase_03 AC 108 ms
40,052 KB
testcase_04 AC 120 ms
41,728 KB
testcase_05 AC 122 ms
42,216 KB
testcase_06 AC 114 ms
41,216 KB
testcase_07 AC 101 ms
40,548 KB
testcase_08 AC 93 ms
36,736 KB
testcase_09 AC 122 ms
43,112 KB
testcase_10 AC 134 ms
44,032 KB
testcase_11 AC 91 ms
36,224 KB
testcase_12 AC 110 ms
52,468 KB
testcase_13 AC 139 ms
66,300 KB
testcase_14 AC 94 ms
44,800 KB
testcase_15 AC 92 ms
45,056 KB
testcase_16 AC 136 ms
66,788 KB
testcase_17 AC 96 ms
43,904 KB
testcase_18 AC 129 ms
55,116 KB
testcase_19 AC 78 ms
36,864 KB
testcase_20 AC 68 ms
33,024 KB
testcase_21 AC 80 ms
36,864 KB
testcase_22 AC 147 ms
58,112 KB
testcase_23 AC 140 ms
59,656 KB
testcase_24 AC 142 ms
66,184 KB
testcase_25 AC 145 ms
59,988 KB
testcase_26 AC 138 ms
59,828 KB
testcase_27 AC 143 ms
66,132 KB
testcase_28 AC 149 ms
65,992 KB
testcase_29 AC 140 ms
65,916 KB
testcase_30 AC 145 ms
59,852 KB
testcase_31 AC 147 ms
59,896 KB
testcase_32 AC 140 ms
64,056 KB
testcase_33 AC 135 ms
48,096 KB
testcase_34 AC 144 ms
47,964 KB
testcase_35 AC 137 ms
47,872 KB
testcase_36 AC 137 ms
47,872 KB
testcase_37 AC 140 ms
48,000 KB
testcase_38 AC 135 ms
48,000 KB
testcase_39 AC 135 ms
48,000 KB
testcase_40 AC 136 ms
47,872 KB
testcase_41 AC 139 ms
47,872 KB
testcase_42 AC 134 ms
206,440 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (85 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;

namespace test
{
    static class Program
    {
        static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            string[] astr = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            for(int i = 0; i < n; i++)
            {
                a[i] = long.Parse(astr[i]);
            }
            Dictionary<long,long> dict = new Dictionary<long,long>();
            for (int i = 0; i < n; i++)
            {
                if (dict.ContainsKey(a[i] - 1))
                {
                    if (dict.ContainsKey(a[i]))
                    {
                        dict[a[i]] = (dict[a[i]] +dict[a[i] - 1] + 1)%998244353;
                    }
                    else
                    {
                        dict.Add(a[i], (dict[a[i] - 1] + 1)%998244353);
                    }
                }
                else
                {
                    if (dict.ContainsKey(a[i]))
                    {
                        dict[a[i]] = (dict[a[i]]+1)%998244353;
                    }
                    else
                    {
                        dict.Add(a[i], 1);
                    }
                }
            }
            long count = 0;
            foreach (var item in dict)
            {
                count += item.Value;
            }
            Console.WriteLine((count - n+998244353)%998244353);
        }
    }
}
0