結果

問題 No.2008 Super Worker
ユーザー LyricalMaestro
提出日時 2025-05-03 00:22:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,200 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 141,032 KB
最終ジャッジ日時 2025-05-03 00:22:28
合計ジャッジ時間 17,497 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2008

from functools import cmp_to_key

MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    array = [(A[i], B[i]) for i in range(N)]


    def compare_items(a, b):
        if (a[0] + b[0] * a[1]) > (b[0] + a[0] * b[1]):
            return 1
        elif (a[0] + b[0] * a[1]) < (b[0] + a[0] * b[1]):
            return -1
        else:
            return 0

    sorted_list = sorted(array, key=cmp_to_key(compare_items), reverse=True)

    answer = 0
    level = 1
    for a, b in sorted_list:
        answer += (a * level) % MOD
        answer %= MOD

        level *= b
        level %= MOD

    print(answer)




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