結果
問題 | No.1645 AB's abs |
ユーザー | tenten |
提出日時 | 2021-08-16 14:54:46 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,452 bytes |
コンパイル時間 | 2,275 ms |
コンパイル使用メモリ | 76,968 KB |
実行使用メモリ | 50,108 KB |
最終ジャッジ日時 | 2024-04-17 17:40:08 |
合計ジャッジ時間 | 5,760 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
37,328 KB |
testcase_01 | AC | 42 ms
36,984 KB |
testcase_02 | AC | 49 ms
37,764 KB |
testcase_03 | AC | 45 ms
37,220 KB |
testcase_04 | AC | 44 ms
37,204 KB |
testcase_05 | AC | 43 ms
37,328 KB |
testcase_06 | AC | 43 ms
37,172 KB |
testcase_07 | AC | 43 ms
37,184 KB |
testcase_08 | AC | 51 ms
38,824 KB |
testcase_09 | AC | 51 ms
38,620 KB |
testcase_10 | AC | 50 ms
38,600 KB |
testcase_11 | AC | 50 ms
38,340 KB |
testcase_12 | AC | 51 ms
38,280 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
import java.io.*; import java.util.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int base = n * 100; int[][] dp = new int[n + 1][base * 2 + 1]; dp[0][base] = 1; for (int i = 1; i <= n; i++) { int x = sc.nextInt(); for (int j = 0; j < dp[i].length; j++) { if (dp[i - 1][j] > 0) { dp[i][j + x] += dp[i - 1][j]; dp[i][j - x] += dp[i - 1][j]; } } } long ans = 0; for (int i = 0; i < dp[n].length; i++) { long value = Math.abs(i - base); ans += value * dp[n][i] % MOD; ans %= MOD; } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }