結果

問題 No.2046 Ans Mod? Mod Ans!
ユーザー mkawa2mkawa2
提出日時 2023-02-27 23:33:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,347 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 77,776 KB
最終ジャッジ日時 2023-10-13 07:48:36
合計ジャッジ時間 9,247 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,288 KB
testcase_01 AC 72 ms
71,376 KB
testcase_02 AC 72 ms
71,276 KB
testcase_03 AC 100 ms
76,972 KB
testcase_04 AC 95 ms
76,524 KB
testcase_05 AC 98 ms
76,780 KB
testcase_06 AC 97 ms
77,036 KB
testcase_07 AC 95 ms
76,856 KB
testcase_08 AC 183 ms
77,148 KB
testcase_09 AC 178 ms
77,344 KB
testcase_10 AC 212 ms
77,420 KB
testcase_11 AC 283 ms
77,408 KB
testcase_12 AC 249 ms
77,776 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

def binary_search(l, r, minimize):
    if minimize: l -= 1
    else: r += 1
    while l+1 < r:
        m = (l+r)//2
        if ok(m) ^ minimize: l = m
        else: r = m
    if minimize: return r
    return l

def ok(m):
    return a//aa[m] < f

# a>=b
# b-a%b
# b-(a-b*(a//b))
# b-a+b*(a//b)

n = II()
aa = LI()

aa.sort()
ans = l = 0
for i, a in enumerate(aa):
    ans += l-a*i
    l += a

cs = [0]*(n+1)
for i in range(n): cs[i+1] = cs[i]+aa[i]

for i, a in enumerate(aa):
    l = 0
    while l < i:
        f = a//aa[l]
        r = binary_search(l+1, i, True)
        ans += (cs[r]-cs[l])*f
        l = r

print(ans)
0