結果

問題 No.1233 割り切れない気持ち
ユーザー NoneNone
提出日時 2021-03-16 01:53:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 3,153 ms
コード長 648 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 128,000 KB
最終ジャッジ日時 2024-04-25 04:10:24
合計ジャッジ時間 6,118 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,584 KB
testcase_01 AC 35 ms
52,096 KB
testcase_02 AC 38 ms
52,224 KB
testcase_03 AC 51 ms
60,800 KB
testcase_04 AC 46 ms
60,672 KB
testcase_05 AC 37 ms
52,096 KB
testcase_06 AC 35 ms
52,096 KB
testcase_07 AC 93 ms
89,728 KB
testcase_08 AC 114 ms
100,736 KB
testcase_09 AC 162 ms
118,656 KB
testcase_10 AC 160 ms
121,472 KB
testcase_11 AC 91 ms
87,680 KB
testcase_12 AC 170 ms
121,856 KB
testcase_13 AC 167 ms
122,240 KB
testcase_14 AC 171 ms
107,320 KB
testcase_15 AC 173 ms
121,984 KB
testcase_16 AC 172 ms
121,856 KB
testcase_17 AC 83 ms
103,296 KB
testcase_18 AC 141 ms
125,824 KB
testcase_19 AC 106 ms
121,088 KB
testcase_20 AC 82 ms
103,296 KB
testcase_21 AC 111 ms
108,544 KB
testcase_22 AC 111 ms
108,544 KB
testcase_23 AC 110 ms
108,416 KB
testcase_24 AC 118 ms
109,056 KB
testcase_25 AC 111 ms
108,800 KB
testcase_26 AC 111 ms
108,672 KB
testcase_27 AC 134 ms
128,000 KB
testcase_28 AC 139 ms
127,616 KB
testcase_29 AC 133 ms
127,232 KB
testcase_30 AC 133 ms
127,488 KB
testcase_31 AC 136 ms
127,744 KB
testcase_32 AC 133 ms
127,232 KB
testcase_33 AC 132 ms
127,744 KB
testcase_34 AC 130 ms
127,744 KB
testcase_35 AC 135 ms
127,744 KB
testcase_36 AC 136 ms
127,872 KB
testcase_37 AC 36 ms
51,584 KB
testcase_38 AC 103 ms
121,728 KB
testcase_39 AC 131 ms
105,728 KB
testcase_40 AC 131 ms
105,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def deg(A):
    """
    連続して続く文字を圧縮する(※Counterではない)
    [1,1,1,2,2,2,3] -> [(1,3),(2,3),(3,1)]
    """
    res=[]
    a0, cnt=A[0], 1
    for a in A[1:]+[None]:
        if a!=a0: res.append((a0,cnt)); cnt=1
        else: cnt+=1
        a0=a
    return res

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int, input().split()))
A.sort()
M=max(A)
S=[0]*(M+1)
for a in A:
    S[a]+=1
C=[0]
for a in S:
    C.append(C[-1]+a)

res=N*sum(A)
for a,cnt in deg(A):
    l,r=0,a-1
    k=0
    while l+a<=M:
        l+=a
        r+=a
        k+=1
        res-=(C[min(r+1,M+1)]-C[l])*k*a*cnt

print(res)
0