結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー tamatotamato
提出日時 2021-11-05 22:24:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,706 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 174,880 KB
最終ジャッジ日時 2024-04-24 06:15:22
合計ジャッジ時間 19,060 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 275 ms
126,384 KB
testcase_01 AC 209 ms
120,192 KB
testcase_02 AC 208 ms
120,316 KB
testcase_03 AC 272 ms
120,960 KB
testcase_04 AC 281 ms
120,704 KB
testcase_05 AC 284 ms
120,448 KB
testcase_06 AC 267 ms
120,576 KB
testcase_07 AC 273 ms
120,624 KB
testcase_08 AC 247 ms
120,320 KB
testcase_09 AC 224 ms
120,704 KB
testcase_10 AC 266 ms
120,576 KB
testcase_11 AC 204 ms
120,552 KB
testcase_12 AC 215 ms
120,576 KB
testcase_13 AC 1,706 ms
165,768 KB
testcase_14 AC 1,657 ms
166,148 KB
testcase_15 AC 1,640 ms
166,144 KB
testcase_16 AC 1,679 ms
166,160 KB
testcase_17 AC 1,563 ms
165,760 KB
testcase_18 AC 1,192 ms
163,136 KB
testcase_19 AC 1,339 ms
174,880 KB
testcase_20 AC 332 ms
127,164 KB
testcase_21 AC 352 ms
127,504 KB
testcase_22 AC 292 ms
126,380 KB
testcase_23 AC 262 ms
127,616 KB
testcase_24 AC 270 ms
127,612 KB
testcase_25 AC 1,302 ms
167,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
NN = 10 ** 6


def main():
    import sys
    from collections import Counter
    input = sys.stdin.readline

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

    div = [[] for _ in range(NN + 1)]
    for i in range(201, NN+1):
        for x in range(1, NN+1):
            if i * x > NN:
                break
            if i * x in C:
                div[i*x].append(i)

    cnt = [N] * (NN+1)
    for a in C:
        k = C[a]
        for d in div[a]:
            cnt[d] -= k
        for d in range(1, 201):
            if a % d == 0:
                cnt[d] -= k

    ans = [1] * (N+1)
    for x in range(1, NN+1):
        k = cnt[x]
        ans[k] = x
    for i in range(1, N+1):
        ans[i] = max(ans[i], ans[i-1])
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()
0