結果

問題 No.2008 Super Worker
ユーザー ygd.
提出日時 2022-10-04 22:29:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,168 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 54,524 KB
最終ジャッジ日時 2024-12-30 12:38:22
合計ジャッジ時間 28,588 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
import math
import bisect
#import itertools
#import random
from heapq import heapify, heappop, heappush
from collections import defaultdict 
#from collections import deque
import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

from functools import cmp_to_key

def compare(x,y): #aが大きいとき1
    a1,b1 = x
    a2,b2 = y
    p = a1 + a2*b1
    q = a2 + a1*b2
    if p == q: return 0
    if p < q: return 1
    if p > q: return -1

def main():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = []
    for a,b in zip(A,B):
        C.append((a,b))
    
    C.sort(key = cmp_to_key(compare))
    # print(C)

    level = 1
    ans = 0
    for a,b in C:
        ans += level*a
        ans %= MOD
        level *= b
        level %= MOD
    print(ans)
    



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