結果

問題 No.1233 割り切れない気持ち
ユーザー uni_pythonuni_python
提出日時 2020-09-20 15:53:40
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 951 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 108,824 KB
最終ジャッジ日時 2023-09-06 16:20:49
合計ジャッジ時間 26,471 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,296 KB
testcase_01 AC 74 ms
71,152 KB
testcase_02 AC 82 ms
75,012 KB
testcase_03 AC 103 ms
76,580 KB
testcase_04 AC 103 ms
76,396 KB
testcase_05 AC 86 ms
75,020 KB
testcase_06 AC 83 ms
75,084 KB
testcase_07 AC 437 ms
83,332 KB
testcase_08 AC 728 ms
88,952 KB
testcase_09 AC 1,442 ms
101,344 KB
testcase_10 AC 1,514 ms
104,892 KB
testcase_11 AC 408 ms
82,836 KB
testcase_12 AC 1,763 ms
108,348 KB
testcase_13 AC 1,743 ms
108,824 KB
testcase_14 AC 1,807 ms
108,340 KB
testcase_15 AC 1,624 ms
108,616 KB
testcase_16 AC 1,700 ms
108,572 KB
testcase_17 AC 297 ms
105,608 KB
testcase_18 AC 1,706 ms
107,256 KB
testcase_19 AC 338 ms
107,408 KB
testcase_20 AC 116 ms
105,404 KB
testcase_21 AC 373 ms
108,108 KB
testcase_22 AC 374 ms
107,680 KB
testcase_23 AC 370 ms
107,944 KB
testcase_24 AC 370 ms
108,116 KB
testcase_25 AC 368 ms
108,284 KB
testcase_26 AC 368 ms
108,380 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
A[i]=aを見る時
aより小さい数は全部そのまま足す,
aより大きく,2aより小さいものは全部足して,個数*aを引く
"""
def main():
    import bisect
    
    mod=10**9+7
    N=I()
    A=LI()
    A.sort()
    M=A[-1]
    S=[0]*(N+1)
    
    for i in range(N):
        S[i+1]=S[i]+A[i]
        
    def calc(a):
        if a==1:
            return 0
        
        res=0
        now=a
        while now<=M+a:
            num1=bisect.bisect_left(A,now-a)
            num2=bisect.bisect_left(A,now)
            temp=S[num2] - S[num1]
            temp-=(num2-num1)*(now-a)
            res+=temp
            
            now+=a
        return res
    
    ans=0
    for a in A:
        ans+=calc(a)
        
    print(ans)
            
            


main()
0