結果

問題 No.1645 AB's abs
ユーザー tentententen
提出日時 2022-09-29 10:05:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,577 bytes
コンパイル時間 3,296 ms
コンパイル使用メモリ 74,672 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2023-08-24 04:49:50
合計ジャッジ時間 7,058 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,372 KB
testcase_01 AC 41 ms
49,280 KB
testcase_02 AC 44 ms
49,396 KB
testcase_03 AC 42 ms
49,332 KB
testcase_04 AC 43 ms
49,508 KB
testcase_05 AC 42 ms
49,492 KB
testcase_06 AC 42 ms
49,544 KB
testcase_07 AC 41 ms
49,516 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 44 ms
49,572 KB
testcase_11 AC 45 ms
49,476 KB
testcase_12 AC 44 ms
49,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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

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[] current = new int[1];
        current[0] = 1;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int[] next = new int[max + x + 1];
            for (int j = 0; j <= max; j++) {
                next[j + x] += current[j];
                next[Math.abs(j - x)] += current[j];
            }
            max += x;
            current = next;
        }
        long ans = 0;
        for (int i = 1; i < current.length; i++) {
            ans += (long)i * current[i] % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
    
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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0