結果

問題 No.2178 Payable Magic Items
ユーザー aaaaaaaaaa2230
提出日時 2023-01-06 23:30:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 434 ms / 4,000 ms
コード長 502 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 106,968 KB
最終ジャッジ日時 2024-12-14 18:06:59
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
S = [list(map(int,input())) for i in range(n)]
M = 5**k

high = [0]*M

def cost(s):
    c = 0
    for i in s:
        c *= 5
        c += i
    return c

for s in S:
    c = cost(s)
    high[c] += 1


for i in range(k):
    di = 5**i
    mod = 5**(i+1)
    for j in range(M)[::-1]:
        x = j%mod
        x //= di
        if x == 0:
            continue
        high[j-di] += high[j]

ans = 0
for s in S:
    c = cost(s)
    if high[c] > 1:
        ans += 1
print(ans)
0