結果
問題 | No.1645 AB's abs |
ユーザー | tenten |
提出日時 | 2023-04-17 17:50:25 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,110 bytes |
コンパイル時間 | 2,712 ms |
コンパイル使用メモリ | 84,480 KB |
実行使用メモリ | 50,244 KB |
最終ジャッジ日時 | 2024-10-12 19:26:43 |
合計ジャッジ時間 | 6,626 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
37,208 KB |
testcase_01 | AC | 51 ms
37,092 KB |
testcase_02 | AC | 56 ms
37,796 KB |
testcase_03 | AC | 50 ms
37,000 KB |
testcase_04 | AC | 51 ms
37,068 KB |
testcase_05 | AC | 50 ms
37,008 KB |
testcase_06 | AC | 51 ms
37,348 KB |
testcase_07 | AC | 51 ms
37,216 KB |
testcase_08 | AC | 60 ms
38,756 KB |
testcase_09 | AC | 63 ms
38,588 KB |
testcase_10 | AC | 60 ms
38,228 KB |
testcase_11 | AC | 63 ms
38,472 KB |
testcase_12 | AC | 61 ms
38,336 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.*; import java.util.stream.*; 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[][] counts = new int[n + 1][n * 2 * 100 + 1]; counts[0][n * 100] = 1; for (int i = 1; i <= n; i++) { int x = sc.nextInt(); for (int j = 0; j < counts[i].length; j++) { if (counts[i - 1][j] > 0) { counts[i][j - x] += counts[i - 1][j]; counts[i][j + x] += counts[i - 1][j]; } } } long ans = 0; for (int i = 0; i < counts[n].length; i++) { ans += Math.abs(i - n * 100L) * counts[n][i] % MOD; ans %= MOD; } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }