結果

問題 No.2046 Ans Mod? Mod Ans!
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-08-19 22:04:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 4,000 ms
コード長 429 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 112,096 KB
最終ジャッジ日時 2023-08-22 11:40:48
合計ジャッジ時間 3,608 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
77,580 KB
testcase_01 AC 84 ms
77,436 KB
testcase_02 AC 83 ms
77,572 KB
testcase_03 AC 94 ms
78,028 KB
testcase_04 AC 88 ms
77,924 KB
testcase_05 AC 90 ms
78,132 KB
testcase_06 AC 88 ms
78,032 KB
testcase_07 AC 91 ms
78,140 KB
testcase_08 AC 88 ms
78,116 KB
testcase_09 AC 92 ms
77,896 KB
testcase_10 AC 91 ms
78,264 KB
testcase_11 AC 90 ms
78,268 KB
testcase_12 AC 89 ms
78,096 KB
testcase_13 AC 123 ms
89,860 KB
testcase_14 AC 112 ms
86,464 KB
testcase_15 AC 139 ms
95,780 KB
testcase_16 AC 138 ms
95,748 KB
testcase_17 AC 131 ms
93,432 KB
testcase_18 AC 139 ms
93,444 KB
testcase_19 AC 130 ms
93,644 KB
testcase_20 AC 179 ms
112,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


n=int(input())
a=list(map(int,input().split()))
a.sort()
cnt=[0]*(2*10**5+100)
wa=[0]*(n+3)
for i in range(n-1,-1,-1):
    cnt[a[i]]+=1
    wa[i]=wa[i+1]+a[i]
for i in range(2*10**5,-1,-1):
    cnt[i]+=cnt[i+1]
ans=0
for i in range(n):
    res=0
    res+=a[i]*(n-1-i)
    res-=wa[i+1]
    for p in range(a[i],2*10**5+1,a[i]):
        if p==a[i]:res+=a[i]*(cnt[p]-1)
        else:res+=a[i]*cnt[p]

    ans+=res
print(ans)






0