結果

問題 No.1645 AB's abs
ユーザー CleyLCleyL
提出日時 2023-01-09 13:31:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 73,288 KB
実行使用メモリ 11,852 KB
最終ジャッジ日時 2023-08-22 17:06:35
合計ジャッジ時間 2,212 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 5 ms
4,488 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 13 ms
7,720 KB
testcase_14 AC 11 ms
6,692 KB
testcase_15 AC 14 ms
7,944 KB
testcase_16 AC 13 ms
7,656 KB
testcase_17 AC 13 ms
7,628 KB
testcase_18 AC 12 ms
7,140 KB
testcase_19 AC 13 ms
7,572 KB
testcase_20 AC 11 ms
6,644 KB
testcase_21 AC 13 ms
7,432 KB
testcase_22 AC 13 ms
7,596 KB
testcase_23 AC 12 ms
7,576 KB
testcase_24 AC 13 ms
7,716 KB
testcase_25 AC 14 ms
7,948 KB
testcase_26 AC 13 ms
7,628 KB
testcase_27 AC 14 ms
7,880 KB
testcase_28 AC 13 ms
7,692 KB
testcase_29 AC 13 ms
7,804 KB
testcase_30 AC 14 ms
8,336 KB
testcase_31 AC 14 ms
8,052 KB
testcase_32 AC 14 ms
8,284 KB
testcase_33 AC 19 ms
10,876 KB
testcase_34 AC 20 ms
10,840 KB
testcase_35 AC 20 ms
10,968 KB
testcase_36 AC 20 ms
10,920 KB
testcase_37 AC 20 ms
10,920 KB
testcase_38 AC 12 ms
11,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
long long mod = 998244353;
long long dp[110][20010];
int main(){
  dp[0][10005] = 1;
  int n;cin>>n;
  vector<long long> A(n);
  for(int i = 0; n > i; i++)cin>>A[i];
  for(int i = 0; n > i; i++){
    for(int j = 0; 20010 > j; j++){
      if(!dp[i][j])continue;
      dp[i+1][j+A[i]] = (dp[i+1][j+A[i]]+dp[i][j])%mod;
      dp[i+1][j-A[i]] = (dp[i+1][j-A[i]]+dp[i][j])%mod;
    }
  }
  long long ans = 0;
  for(long long j = 0; 20010 > j; j++){
    ans = (ans+abs(10005-j)*dp[n][j])%mod;
  }
  cout << ans << endl;
}
0