結果

問題 No.2008 Super Worker
ユーザー qibqib
提出日時 2022-10-15 18:27:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 461 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 166,244 KB
最終ジャッジ日時 2023-09-09 02:59:35
合計ジャッジ時間 34,377 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 230 ms
89,216 KB
testcase_01 AC 227 ms
89,080 KB
testcase_02 AC 226 ms
89,216 KB
testcase_03 AC 229 ms
89,016 KB
testcase_04 AC 230 ms
89,348 KB
testcase_05 AC 228 ms
89,100 KB
testcase_06 AC 223 ms
89,076 KB
testcase_07 AC 225 ms
89,276 KB
testcase_08 AC 231 ms
89,048 KB
testcase_09 AC 230 ms
89,076 KB
testcase_10 AC 226 ms
89,396 KB
testcase_11 AC 225 ms
89,128 KB
testcase_12 AC 230 ms
89,156 KB
testcase_13 AC 258 ms
90,792 KB
testcase_14 AC 254 ms
90,844 KB
testcase_15 AC 253 ms
90,724 KB
testcase_16 AC 254 ms
90,940 KB
testcase_17 AC 255 ms
90,968 KB
testcase_18 AC 266 ms
91,272 KB
testcase_19 AC 249 ms
90,752 KB
testcase_20 AC 260 ms
90,856 KB
testcase_21 AC 258 ms
90,876 KB
testcase_22 AC 249 ms
90,764 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 494 ms
143,660 KB
testcase_34 TLE -
testcase_35 AC 445 ms
139,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

from fractions import Fraction

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cur = 1
inv = {}
for i in range(n):
  cur = (cur * b[i]) % MOD
  if not b[i] in inv:
    inv[b[i]] = pow(b[i], MOD - 2, MOD)

order = [i for i in range(n)]
order.sort(key=lambda i: Fraction(b[i] - 1, a[i]))

ans = 0
for i in order:
  ans = (ans + cur * a[i] * inv[b[i]]) % MOD
  cur = (cur * inv[b[i]]) % MOD

print(ans)
0