結果

問題 No.2008 Super Worker
ユーザー lam6er
提出日時 2025-03-20 20:23:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,410 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,760 KB
実行使用メモリ 148,868 KB
最終ジャッジ日時 2025-03-20 20:25:55
合計ジャッジ時間 19,218 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import cmp_to_key

MOD = 10**9 + 7

def main():
    n = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().split()))
    B = list(map(int, sys.stdin.readline().split()))
    jobs = list(zip(A, B))
    
    def compare(job1, job2):
        a1, b1 = job1
        a2, b2 = job2
        lhs = a1 * (1 - b2)
        rhs = a2 * (1 - b1)
        if lhs > rhs:
            return -1
        elif lhs < rhs:
            return 1
        else:
            return 0
    
    jobs.sort(key=cmp_to_key(compare))
    
    total = 0
    product = 1  # initial level is 1
    
    for a, b in jobs:
        total = (total + a * product) % MOD
        product = (product * b) % MOD
    
    print(total % MOD)

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