結果
| 問題 |
No.1645 AB's abs
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-13 21:56:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 539 bytes |
| コンパイル時間 | 1,767 ms |
| コンパイル使用メモリ | 172,428 KB |
| 実行使用メモリ | 19,712 KB |
| 最終ジャッジ日時 | 2024-10-03 18:39:47 |
| 合計ジャッジ時間 | 3,545 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int main(){
int N;
cin>>N;
vector<int>A(N);
for(int i=0;i<N;i+=1)cin>>A[i];
vector<vector<long long>>dp(N+1,vector<long long>(N*203));
dp[0][N*100]=1;
for(int i=0;i<N;i+=1){
for(int j=0;j<N*203;j+=1){
if(j-A[i]>=0)dp[i+1][j]=(dp[i+1][j]+dp[i][j-A[i]])%mod;
if(j+A[i]<N*203)dp[i+1][j]=(dp[i+1][j]+dp[i][j+A[i]])%mod;
}
}
long long ans=0;
for(int i=0;i<203*N;i+=1){
ans=(ans+abs(i-N*100)*dp[N][i])%mod;
}
cout<<ans<<'\n';
}