結果

問題 No.2008 Super Worker
ユーザー AkariAkari
提出日時 2022-07-15 21:41:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,647 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 29,860 KB
最終ジャッジ日時 2023-09-10 01:05:17
合計ジャッジ時間 11,038 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,704 KB
testcase_01 AC 133 ms
29,616 KB
testcase_02 AC 134 ms
29,652 KB
testcase_03 AC 134 ms
29,700 KB
testcase_04 AC 136 ms
29,672 KB
testcase_05 AC 134 ms
29,600 KB
testcase_06 AC 136 ms
29,588 KB
testcase_07 AC 137 ms
29,692 KB
testcase_08 AC 135 ms
29,656 KB
testcase_09 AC 134 ms
29,648 KB
testcase_10 AC 135 ms
29,612 KB
testcase_11 AC 136 ms
29,600 KB
testcase_12 AC 134 ms
29,708 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

def cmp(a, b):
    a1, b1 = a
    a2, b2 = b
    return a1 + a2 * b1 >= a2 + a1 * b2


def argsort(A):
    n = A.shape[0]
    length = 20
    INF = np.zeros(2, np.int64)
    INF[1] = 1 << 60
    index = np.arange(n)
    work = np.empty(n, np.int64)
    for l in range(0, n, length):
        r = min(l + length, n)
        for i in range(l+1, r):
            if cmp(A[index[i-1]], A[index[i]]): continue
            tmp = index[i]
            a = A[tmp]
            j = i
            while j > l and not cmp(A[index[j-1]], a):
                index[j] = index[j-1]
                j -= 1
            index[j] = tmp
    while length < n:
        work = index.copy()
        for l in range(0, n, 2 * length):
            li, ri = l, min(l + length, n)
            l_max, r_max = min(li + length, n), min(ri + length, n)
            tot = (l_max - li) + (r_max - ri)
            for i in range(l, l+tot):
                a = A[work[li]] if li < l_max else INF
                b = A[work[ri]] if ri < r_max else INF
                if cmp(a, b):
                    index[i] = work[li]
                    li += 1
                else:
                    index[i] = work[ri]
                    ri += 1
        length <<= 1
    return index





def main():
    n = int(input())
    AB = np.fromstring(sys.stdin.read(), np.int64, sep=' ').reshape(2, -1).T
    x = 1
    ans = 0
    mod = 1_000_000_007
    idx = argsort(AB)
    AB = AB[idx]
    for i in range(n):
        a, b = AB[i]
        ans += a * x
        ans %= mod
        x *= b
        x %= mod
    print(ans)
    
    

if __name__ == '__main__':
    main()
0