結果
問題 |
No.1645 AB's abs
|
ユーザー |
|
提出日時 | 2021-09-04 12:01:19 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 254 ms / 2,000 ms |
コード長 | 1,462 bytes |
コンパイル時間 | 9,505 ms |
コンパイル使用メモリ | 169,328 KB |
実行使用メモリ | 185,688 KB |
最終ジャッジ日時 | 2024-12-17 19:56:19 |
合計ジャッジ時間 | 16,717 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (93 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; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace yukicoder { class Program { const int intMax = 1000000000; const long longMax = 2000000000000000000; static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split().Select(int.Parse).ToArray(); var dp = new Dictionary<int, long>(); long mod = 998244353; dp[0] = 1; for(int i = 0; i < N; i++) { var temp = new Dictionary<int, long>(); foreach(var d in dp) { if(!temp.ContainsKey(d.Key + A[i])) { temp.Add(d.Key + A[i],0); } if(!temp.ContainsKey(d.Key - A[i])) { temp.Add(d.Key - A[i],0); } temp[d.Key + A[i]] = (temp[d.Key + A[i]] + d.Value) % mod; temp[d.Key - A[i]] = (temp[d.Key - A[i]] + d.Value) % mod; } dp = temp; } long ans = 0; foreach(var d in dp) { ans = (ans + (Math.Abs(d.Key) * d.Value) % mod ) % mod; } Console.WriteLine(ans); } } }