結果
| 問題 |
No.1645 AB's abs
|
| コンテスト | |
| ユーザー |
Drice27149
|
| 提出日時 | 2021-08-13 21:40:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 673 bytes |
| コンパイル時間 | 720 ms |
| コンパイル使用メモリ | 64,372 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-10-03 17:59:05 |
| 合計ジャッジ時間 | 2,315 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include <cstdio>
#include <iostream>
using std::string;
const long long mod = 998244353;
long long f[105][20005];
//int a[105];
int main(){
int n;
scanf("%d",&n);
int off = 10001;
f[0][off] = 1;
long long ans = 0;
for(int i = 1; i <= n; i++){
int u;
scanf("%d",&u);
for(int j = -10000; j <= 10000; j++){
f[i][j+off] = 0;
int last = j-u;
if(last>=-10000) f[i][j+off] += f[i-1][last+off];
f[i][j+off] %= mod;
last = j+u;
if(last<=10000) f[i][j+off] += f[i-1][last+off];
f[i][j+off] %= mod;
if(i==n){
long long val = j;
if(j<0) val *= -1;
ans = (ans + val*f[i][j+off]%mod)%mod;
}
}
}
printf("%lld\n",ans);
return 0;
}
Drice27149