結果

問題 No.1917 LCMST
コンテスト
ユーザー PNJ
提出日時 2024-08-29 19:42:20
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 449 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 371 ms
コンパイル使用メモリ 85,056 KB
実行使用メモリ 210,196 KB
最終ジャッジ日時 2026-04-03 23:28:08
合計ジャッジ時間 12,431 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = list(map(int,input().split()))
M = 100000
B = [0] * (M + 1)
m = min(A)

for a in A:
  B[a] += 1

ans = 0
for a in range(1,M + 1):
  if B[a] == 0:
    continue
  ans += a * (B[a] - 1)
  B[a] = 1

for a in range(2,M + 1):
  if B[a] == 0:
    continue
  for i in range(2,M + 1):
    if a * i > M:
      break
    if B[a * i]:
      B[a * i] = 0
      ans += a * i
for a in range(m + 1,M + 1):
  if B[a]:
    ans += a * m
print(ans)
0