結果

問題 No.1645 AB's abs
ユーザー atjh16atjh16
提出日時 2021-09-23 16:49:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 529 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 165,380 KB
実行使用メモリ 19,280 KB
最終ジャッジ日時 2023-09-18 19:54:20
合計ジャッジ時間 3,563 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 10 ms
8,032 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 4 ms
4,640 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 12 ms
9,444 KB
testcase_09 AC 12 ms
9,440 KB
testcase_10 AC 11 ms
8,984 KB
testcase_11 AC 11 ms
8,820 KB
testcase_12 AC 11 ms
9,016 KB
testcase_13 AC 27 ms
18,936 KB
testcase_14 AC 25 ms
17,728 KB
testcase_15 AC 27 ms
18,664 KB
testcase_16 AC 26 ms
18,340 KB
testcase_17 AC 26 ms
18,496 KB
testcase_18 AC 26 ms
17,976 KB
testcase_19 AC 27 ms
18,656 KB
testcase_20 AC 24 ms
17,696 KB
testcase_21 AC 26 ms
18,032 KB
testcase_22 AC 27 ms
18,504 KB
testcase_23 AC 28 ms
19,064 KB
testcase_24 AC 27 ms
18,968 KB
testcase_25 AC 27 ms
18,992 KB
testcase_26 AC 28 ms
19,136 KB
testcase_27 AC 28 ms
18,964 KB
testcase_28 AC 28 ms
19,280 KB
testcase_29 AC 28 ms
19,136 KB
testcase_30 AC 28 ms
18,988 KB
testcase_31 AC 28 ms
18,964 KB
testcase_32 AC 27 ms
19,112 KB
testcase_33 AC 27 ms
18,968 KB
testcase_34 AC 28 ms
18,964 KB
testcase_35 AC 28 ms
19,020 KB
testcase_36 AC 28 ms
19,028 KB
testcase_37 AC 27 ms
19,064 KB
testcase_38 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:29:33: 警告: iteration 9999 invokes undefined behavior [-Waggressive-loop-optimizations]
   29 |                 m = (m + dp[n][i] * (i - 10001) * 2) % M;
      |                          ~~~~~~~^
main.cpp:28:37: 備考: within this loop
   28 |         for (long long i = 10002; i <= 20001; i++)
      |                                   ~~^~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, a;
const int N = 20001;
long long m = 0;
long long dp[101][N];
const long long M = 998244353;

int main()
{
	cin >> n;

	dp[0][10001] = 1;

	for (int i = 1; i <= n; i++) {
		cin >> a;

		for (int j = 0; j < N; j++) {
			if (j >= a)
				dp[i][j] = (dp[i][j] + dp[i - 1][j - a]) % M;

			if (j <= 20001 - a)
				dp[i][j] = (dp[i][j] + dp[i - 1][j + a]) % M;
		}
	}
	
	for (long long i = 10002; i <= 20001; i++)
		m = (m + dp[n][i] * (i - 10001) * 2) % M;

	cout << m << endl;
}
0