結果
問題 | No.2008 Super Worker |
ユーザー | rlangevin |
提出日時 | 2022-08-29 00:20:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,482 bytes |
コンパイル時間 | 291 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 130,464 KB |
最終ジャッジ日時 | 2024-10-15 20:11:12 |
合計ジャッジ時間 | 9,442 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
51,840 KB |
testcase_01 | AC | 43 ms
52,096 KB |
testcase_02 | AC | 43 ms
52,096 KB |
testcase_03 | AC | 41 ms
52,096 KB |
testcase_04 | AC | 40 ms
51,840 KB |
testcase_05 | AC | 39 ms
52,224 KB |
testcase_06 | AC | 37 ms
52,096 KB |
testcase_07 | WA | - |
testcase_08 | AC | 38 ms
52,096 KB |
testcase_09 | AC | 37 ms
52,224 KB |
testcase_10 | AC | 36 ms
52,352 KB |
testcase_11 | AC | 38 ms
52,224 KB |
testcase_12 | AC | 38 ms
52,096 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 97 ms
76,504 KB |
testcase_19 | AC | 82 ms
76,032 KB |
testcase_20 | AC | 99 ms
76,684 KB |
testcase_21 | AC | 88 ms
76,472 KB |
testcase_22 | AC | 90 ms
76,288 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 451 ms
127,352 KB |
testcase_29 | AC | 477 ms
127,352 KB |
testcase_30 | AC | 471 ms
127,596 KB |
testcase_31 | AC | 463 ms
127,984 KB |
testcase_32 | AC | 468 ms
127,472 KB |
testcase_33 | AC | 414 ms
129,308 KB |
testcase_34 | AC | 475 ms
128,368 KB |
testcase_35 | AC | 387 ms
130,464 KB |
ソースコード
inf = 10 ** 18 def merge(A, left, mid, right): mx = (0, inf) L = [0 for i in range(0, mid - left + 1)] R = [0 for j in range(0, right - mid + 1)] L[mid - left] = mx R[right - mid] = mx for i in range(0, mid - left): L[i] = A[left + i] for j in range(0, right - mid): R[j] = A[mid + j] i = 0 j = 0 cnt = 0 for k in range(left, right): Lx, Ly = L[i] Rx, Ry = R[j] if L[i] == mx: A[k] = R[j] j = j + 1 elif R[j] == mx: A[k] = L[i] i = i + 1 elif Lx == 1: A[k] = R[j] j = j + 1 elif Rx == 1: A[k] = L[i] i = i + 1 else: if (Ly - 1) * Rx >= (Ry - 1) * Lx: A[k] = L[i] i = i + 1 else: A[k] = R[j] j = j + 1 cnt = cnt + 1 return A def mergeSort(A, left, right): if left + 1 < right: mid = (left + right) // 2 mergeSort(A, left, mid) mergeSort(A, mid, right) cnt = merge(A, left, mid, right) return cnt N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10 ** 9 + 7 D = [] for i in range(N): D.append((A[i], B[i])) mergeSort(D, 0, N) ans = 0 level = 1 for i in range(N): A, B = D[i] ans += level * A level *= B ans %= mod level %= mod print(ans)