結果

問題 No.1825 Except One
ユーザー rlangevinrlangevin
提出日時 2024-03-26 12:17:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 3,000 ms
コード長 506 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 106,356 KB
最終ジャッジ日時 2024-03-26 12:17:31
合計ジャッジ時間 6,261 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 308 ms
86,920 KB
testcase_04 AC 136 ms
77,904 KB
testcase_05 AC 82 ms
74,096 KB
testcase_06 AC 58 ms
68,780 KB
testcase_07 AC 284 ms
82,716 KB
testcase_08 AC 290 ms
86,548 KB
testcase_09 AC 52 ms
66,172 KB
testcase_10 AC 252 ms
80,672 KB
testcase_11 AC 83 ms
73,400 KB
testcase_12 AC 147 ms
78,288 KB
testcase_13 AC 104 ms
77,404 KB
testcase_14 AC 38 ms
59,596 KB
testcase_15 AC 51 ms
64,092 KB
testcase_16 AC 53 ms
66,168 KB
testcase_17 AC 46 ms
62,012 KB
testcase_18 AC 40 ms
59,596 KB
testcase_19 AC 51 ms
64,072 KB
testcase_20 AC 49 ms
64,084 KB
testcase_21 AC 45 ms
62,012 KB
testcase_22 AC 49 ms
64,088 KB
testcase_23 AC 52 ms
64,092 KB
testcase_24 AC 103 ms
77,408 KB
testcase_25 AC 77 ms
73,024 KB
testcase_26 AC 55 ms
66,160 KB
testcase_27 AC 217 ms
81,552 KB
testcase_28 AC 471 ms
98,464 KB
testcase_29 AC 60 ms
68,256 KB
testcase_30 AC 71 ms
73,340 KB
testcase_31 AC 78 ms
73,192 KB
testcase_32 AC 364 ms
87,828 KB
testcase_33 AC 62 ms
70,332 KB
testcase_34 AC 546 ms
106,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = sorted(list(map(int, input().split())))
ans = 0
C = N + 5
S = sum(A) + 5
pre = [[0] * S for _ in range(C)]
pre[0][0] = 1
for a in A:
    dp = [[0] * S for _ in range(C)]
    for c in range(C):
        for s in range(S):
            dp[c][s] += pre[c][s]
            if c and s - a >= 0:
                dp[c][s] += pre[c - 1][s - a]
                if c >= 2 and s % (c - 1) == 0 and s // (c - 1) >= a:
                    ans += pre[c - 1][s - a]
    pre, dp = dp, pre
    
print(ans)
0