結果

問題 No.2008 Super Worker
ユーザー rlangevinrlangevin
提出日時 2022-08-26 23:42:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,481 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 131,104 KB
最終ジャッジ日時 2024-04-22 01:47:55
合計ジャッジ時間 11,065 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 38 ms
52,736 KB
testcase_02 AC 39 ms
52,488 KB
testcase_03 AC 40 ms
52,352 KB
testcase_04 AC 39 ms
52,480 KB
testcase_05 AC 39 ms
52,224 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 WA -
testcase_08 AC 39 ms
52,736 KB
testcase_09 AC 39 ms
52,480 KB
testcase_10 AC 39 ms
52,480 KB
testcase_11 AC 39 ms
52,480 KB
testcase_12 AC 39 ms
52,096 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 78 ms
76,160 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 90 ms
76,368 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 453 ms
129,132 KB
testcase_34 WA -
testcase_35 AC 444 ms
131,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inf = 10 ** 18
def merge(A, left, mid, right):
    mx = (inf, 0)
    L = [0 for i in range(0, mid - left + 1)]
    R = [0 for j in range(0, right - mid + 1)]
    L[mid - left] = mx
    R[right - mid] = mx
    for i in range(0, mid - left):
        L[i] = A[left + i]
    for j in range(0, right - mid):
        R[j] = A[mid + j] 
    i = 0
    j = 0
    cnt = 0
    for k in range(left, right):
        Lx, Ly = L[i]
        Rx, Ry = R[j]
        if L[i] == mx:
            A[k] = R[j]
            j = j + 1
        elif R[j] == mx:
            A[k] = L[i]
            i = i + 1
        elif Lx == 1:
            A[k] = R[j]
            j = j + 1
        elif Rx == 1:
            A[k] = L[i]
            i = i + 1
        else:
            if Rx * (Ly - 1) > Ry * (Lx - 1):
                A[k] = L[i]
                i = i + 1
            else:
                A[k] = R[j]
                j = j + 1
            cnt = cnt + 1
    return A
 
def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
 
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
 
        cnt = merge(A, left, mid, right)
        return cnt
    
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10 ** 9 + 7
D = []
for i in range(N):
    D.append((A[i], B[i]))
    
mergeSort(D, 0, N)
ans = 0
level = 1
for i in range(N):
    A, B = D[i]
    ans += level * A
    level *= B
    ans %= mod
    level %= mod
print(ans)
0