結果

問題 No.2008 Super Worker
ユーザー とりゐとりゐ
提出日時 2022-07-15 21:27:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 460 ms / 2,000 ms
コード長 941 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 139,732 KB
最終ジャッジ日時 2023-09-10 00:31:51
合計ジャッジ時間 10,143 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,276 KB
testcase_01 AC 75 ms
71,360 KB
testcase_02 AC 73 ms
71,552 KB
testcase_03 AC 73 ms
71,632 KB
testcase_04 AC 72 ms
71,256 KB
testcase_05 AC 74 ms
71,368 KB
testcase_06 AC 74 ms
71,256 KB
testcase_07 AC 73 ms
71,572 KB
testcase_08 AC 73 ms
71,268 KB
testcase_09 AC 71 ms
71,448 KB
testcase_10 AC 73 ms
71,108 KB
testcase_11 AC 73 ms
71,272 KB
testcase_12 AC 74 ms
71,424 KB
testcase_13 AC 111 ms
76,932 KB
testcase_14 AC 114 ms
78,496 KB
testcase_15 AC 101 ms
76,744 KB
testcase_16 AC 110 ms
78,116 KB
testcase_17 AC 111 ms
77,752 KB
testcase_18 AC 117 ms
78,184 KB
testcase_19 AC 95 ms
76,648 KB
testcase_20 AC 102 ms
76,920 KB
testcase_21 AC 110 ms
77,992 KB
testcase_22 AC 101 ms
76,728 KB
testcase_23 AC 449 ms
135,268 KB
testcase_24 AC 445 ms
135,372 KB
testcase_25 AC 455 ms
139,732 KB
testcase_26 AC 460 ms
136,872 KB
testcase_27 AC 449 ms
138,548 KB
testcase_28 AC 453 ms
133,304 KB
testcase_29 AC 447 ms
133,340 KB
testcase_30 AC 449 ms
133,308 KB
testcase_31 AC 448 ms
133,428 KB
testcase_32 AC 439 ms
133,368 KB
testcase_33 AC 337 ms
133,136 KB
testcase_34 AC 440 ms
132,640 KB
testcase_35 AC 324 ms
130,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def compare(x,y):
  # 比較関数 (x<=y)

  a1,b1=x
  a2,b2=y
  if a1+b1*a2>=a2+b2*a1:
    return True
  return False

def merge(l, r):
    new = []
    ln = 0
    rn = 0
    while ln < len(l) and rn < len(r):
        if compare(l[ln],r[rn]):
            new.append(l[ln])
            ln += 1
        else:
            new.append(r[rn])
            rn += 1
    for i in range(ln, len(l)):
        new.append(l[i])
    for i in range(rn, len(r)):
        new.append(r[i])
    return new
 
def MergeSort(l):
    if len(l) == 0:
        return []
    if len(l) == 1:
        return l
    else:
        a = l[:len(l)//2]
        b = l[len(l)//2:]
        return merge(MergeSort(a), MergeSort(b))

mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ab=[]
for i in range(n):
  ab.append((a[i],b[i]))

ab=MergeSort(ab)
ans=0
x=1
for a,b in ab:
  ans+=a*x
  ans%=mod
  x=b*x
  x%=mod

print(ans)
#print(ab)
0