結果

問題 No.1645 AB's abs
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-21 20:35:39
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 13,968 ms
コンパイル使用メモリ 158,888 KB
実行使用メモリ 183,780 KB
最終ジャッジ日時 2024-01-21 20:36:00
合計ジャッジ時間 20,596 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
33,188 KB
testcase_01 AC 76 ms
33,060 KB
testcase_02 AC 105 ms
36,260 KB
testcase_03 AC 76 ms
32,932 KB
testcase_04 AC 78 ms
33,188 KB
testcase_05 AC 79 ms
33,444 KB
testcase_06 AC 81 ms
34,084 KB
testcase_07 AC 78 ms
33,316 KB
testcase_08 AC 98 ms
36,388 KB
testcase_09 AC 98 ms
36,388 KB
testcase_10 AC 96 ms
36,260 KB
testcase_11 AC 98 ms
36,260 KB
testcase_12 AC 97 ms
36,260 KB
testcase_13 AC 145 ms
36,388 KB
testcase_14 AC 123 ms
36,388 KB
testcase_15 AC 126 ms
36,388 KB
testcase_16 AC 125 ms
36,388 KB
testcase_17 AC 126 ms
36,388 KB
testcase_18 AC 122 ms
36,388 KB
testcase_19 AC 125 ms
36,388 KB
testcase_20 AC 121 ms
36,388 KB
testcase_21 AC 123 ms
36,388 KB
testcase_22 AC 131 ms
36,388 KB
testcase_23 AC 126 ms
36,388 KB
testcase_24 AC 127 ms
36,388 KB
testcase_25 AC 127 ms
36,388 KB
testcase_26 AC 129 ms
36,388 KB
testcase_27 AC 125 ms
36,388 KB
testcase_28 AC 127 ms
36,388 KB
testcase_29 AC 127 ms
36,388 KB
testcase_30 AC 130 ms
36,388 KB
testcase_31 AC 130 ms
36,388 KB
testcase_32 AC 131 ms
36,388 KB
testcase_33 AC 128 ms
36,388 KB
testcase_34 AC 129 ms
36,388 KB
testcase_35 AC 127 ms
36,388 KB
testcase_36 AC 126 ms
36,388 KB
testcase_37 AC 127 ms
36,388 KB
testcase_38 AC 130 ms
183,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var mod = 998_244_353;
        var dp = new long[20001];
        dp[10000] = 1;
        for (var i = 0; i < n; ++i)
        {
            var ndp = new long[20001];
            for (var j = 0; j < dp.Length; ++j)
            {
                if (j - a[i] >= 0) ndp[j - a[i]] = (ndp[j - a[i]] + dp[j]) % mod;
                if (j + a[i] < ndp.Length) ndp[j + a[i]] = (ndp[j + a[i]] + dp[j]) % mod;
            }
            dp = ndp;
        }
        var ans = 0L;
        for (var i = 0; i < dp.Length; ++i) ans = (ans + Math.Abs(i - 10000) * dp[i] % mod) % mod;
        WriteLine(ans);
    }
}
0