結果

問題 No.1825 Except One
ユーザー titiatitia
提出日時 2022-01-28 23:32:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 3,000 ms
コード長 605 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 76,788 KB
最終ジャッジ日時 2023-08-30 11:13:13
合計ジャッジ時間 5,357 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,136 KB
testcase_01 AC 72 ms
71,340 KB
testcase_02 AC 79 ms
71,052 KB
testcase_03 AC 136 ms
76,368 KB
testcase_04 AC 102 ms
76,740 KB
testcase_05 AC 90 ms
76,444 KB
testcase_06 AC 81 ms
75,896 KB
testcase_07 AC 128 ms
76,524 KB
testcase_08 AC 128 ms
76,580 KB
testcase_09 AC 82 ms
75,848 KB
testcase_10 AC 115 ms
76,388 KB
testcase_11 AC 97 ms
76,436 KB
testcase_12 AC 103 ms
76,476 KB
testcase_13 AC 96 ms
76,788 KB
testcase_14 AC 76 ms
71,268 KB
testcase_15 AC 81 ms
75,716 KB
testcase_16 AC 82 ms
75,756 KB
testcase_17 AC 75 ms
71,524 KB
testcase_18 AC 74 ms
71,252 KB
testcase_19 AC 76 ms
75,728 KB
testcase_20 AC 77 ms
75,696 KB
testcase_21 AC 76 ms
75,564 KB
testcase_22 AC 78 ms
75,720 KB
testcase_23 AC 76 ms
75,992 KB
testcase_24 AC 85 ms
76,488 KB
testcase_25 AC 82 ms
76,472 KB
testcase_26 AC 80 ms
75,728 KB
testcase_27 AC 101 ms
76,404 KB
testcase_28 AC 134 ms
76,572 KB
testcase_29 AC 84 ms
76,156 KB
testcase_30 AC 81 ms
75,788 KB
testcase_31 AC 93 ms
76,336 KB
testcase_32 AC 135 ms
76,484 KB
testcase_33 AC 79 ms
75,956 KB
testcase_34 AC 142 ms
76,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

# x個なら、和が(x-1)の倍数k*(x-1)で、各数字がk以下

A.sort()

SUM=sum(A)

DP=[[0]*(SUM+1) for i in range(N+1)]
DP[0][0]=1

ANS=0
for a in A:
    for i in range(N-1,-1,-1):
        for j in range(SUM-a,-1,-1):
            if DP[i][j]==0:
                continue

            else:
                if i>=1 and (j+a)%i==0:
                    k=(j+a)//i
                    if a<=k:
                        ANS+=DP[i][j]
                        
                DP[i+1][j+a]+=DP[i][j]

print(ANS)
    
0