結果
| 問題 |
No.2055 12x34...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-21 14:13:23 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 165 ms / 2,000 ms |
| コード長 | 1,466 bytes |
| コンパイル時間 | 7,577 ms |
| コンパイル使用メモリ | 170,148 KB |
| 実行使用メモリ | 205,848 KB |
| 最終ジャッジ日時 | 2024-10-10 06:11:33 |
| 合計ジャッジ時間 | 15,153 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 41 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (94 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/
ソースコード
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);
}
}
}