結果

問題 No.2806 Cornflake Man
ユーザー rlangevin
提出日時 2024-07-12 21:33:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 159,972 KB
最終ジャッジ日時 2024-07-17 20:25:55
合計ジャッジ時間 3,029 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
S = set()
ans = []
for a in A[1:]:
    if a not in S:
        ans.append(a)
        for i in range(a, M + 1, a):
            S.add(i)
            if len(S) > N:
                print(-1)
                exit()
                
S.add(0)
S = sorted(list(S))
if A == S:
    print(len(ans))
    print(*ans)
else:
    print(-1)    
0