結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー vwxyzvwxyz
提出日時 2023-03-20 03:22:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 947 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 81,612 KB
実行使用メモリ 120,332 KB
最終ジャッジ日時 2023-10-18 18:00:59
合計ジャッジ時間 14,227 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 312 ms
104,760 KB
testcase_01 AC 39 ms
55,496 KB
testcase_02 AC 239 ms
83,648 KB
testcase_03 AC 325 ms
83,656 KB
testcase_04 AC 325 ms
83,648 KB
testcase_05 AC 324 ms
83,660 KB
testcase_06 AC 327 ms
83,588 KB
testcase_07 AC 329 ms
83,652 KB
testcase_08 AC 46 ms
55,496 KB
testcase_09 AC 196 ms
81,472 KB
testcase_10 AC 237 ms
81,480 KB
testcase_11 AC 39 ms
53,448 KB
testcase_12 AC 40 ms
55,496 KB
testcase_13 AC 922 ms
116,772 KB
testcase_14 AC 847 ms
116,780 KB
testcase_15 AC 947 ms
116,768 KB
testcase_16 AC 874 ms
116,776 KB
testcase_17 AC 822 ms
116,772 KB
testcase_18 AC 218 ms
120,036 KB
testcase_19 AC 516 ms
120,332 KB
testcase_20 AC 328 ms
103,756 KB
testcase_21 AC 309 ms
103,756 KB
testcase_22 AC 256 ms
104,760 KB
testcase_23 AC 119 ms
109,428 KB
testcase_24 AC 310 ms
111,204 KB
testcase_25 AC 579 ms
119,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline
from collections import Counter

N=int(readline())
A=list(map(int,readline().split()))
C=Counter(A)
M=max(A)
cnt=[N]*(M+1)
for g in range(1,M+1):
    for a in range(g,M+1,g):
        cnt[g]-=C[a]
ans_lst=[0]*N
for i in range(1,M+1):
    if cnt[i]<N:
        ans_lst[cnt[i]]=max(ans_lst[cnt[i]],i)
for i in range(1,N):
    ans_lst[i]=max(ans_lst[i],ans_lst[i-1])
print(*ans_lst,sep="\n")
0