結果

問題 No.1645 AB's abs
ユーザー umezoumezo
提出日時 2021-08-13 21:50:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 200,116 KB
実行使用メモリ 19,256 KB
最終ジャッジ日時 2023-07-27 04:08:55
合計ジャッジ時間 4,273 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 9 ms
8,052 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 4 ms
4,628 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 11 ms
9,420 KB
testcase_09 AC 12 ms
9,472 KB
testcase_10 AC 11 ms
8,796 KB
testcase_11 AC 11 ms
8,784 KB
testcase_12 AC 11 ms
9,012 KB
testcase_13 AC 25 ms
18,628 KB
testcase_14 AC 24 ms
17,892 KB
testcase_15 AC 25 ms
18,920 KB
testcase_16 AC 24 ms
18,156 KB
testcase_17 AC 25 ms
18,788 KB
testcase_18 AC 24 ms
17,912 KB
testcase_19 AC 25 ms
18,836 KB
testcase_20 AC 24 ms
17,440 KB
testcase_21 AC 24 ms
18,064 KB
testcase_22 AC 25 ms
18,536 KB
testcase_23 AC 26 ms
19,012 KB
testcase_24 AC 25 ms
19,008 KB
testcase_25 AC 25 ms
18,988 KB
testcase_26 AC 26 ms
19,088 KB
testcase_27 AC 25 ms
18,948 KB
testcase_28 AC 26 ms
19,032 KB
testcase_29 AC 25 ms
19,256 KB
testcase_30 AC 26 ms
19,008 KB
testcase_31 AC 26 ms
18,992 KB
testcase_32 AC 26 ms
18,948 KB
testcase_33 AC 26 ms
19,004 KB
testcase_34 AC 26 ms
19,016 KB
testcase_35 AC 26 ms
19,008 KB
testcase_36 AC 26 ms
19,156 KB
testcase_37 AC 26 ms
18,984 KB
testcase_38 AC 26 ms
19,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const int MOD=998244353;
ll dp[110][20010];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<int> A(n+1);
  rep(i,n) cin>>A[i+1];
  
  dp[0][10000]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=20000;j++){
      if(j-A[i]>=0) dp[i][j]=(dp[i][j]+dp[i-1][j-A[i]])%MOD;
      if(j+A[i]<=20000) dp[i][j]=(dp[i][j]+dp[i-1][j+A[i]])%MOD;
    }
  }
  ll ans=0;
  for(int i=0;i<=20000;i++) ans=(ans+dp[n][i]*abs(i-10000)%MOD)%MOD;
  cout<<ans<<endl;
  
  return 0;
}
0