結果
問題 | No.2008 Super Worker |
ユーザー | rlangevin |
提出日時 | 2022-08-26 23:45:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,481 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 130,692 KB |
最終ジャッジ日時 | 2024-10-14 00:28:59 |
合計ジャッジ時間 | 8,964 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,096 KB |
testcase_01 | AC | 38 ms
52,096 KB |
testcase_02 | AC | 36 ms
52,480 KB |
testcase_03 | AC | 40 ms
52,096 KB |
testcase_04 | AC | 37 ms
51,840 KB |
testcase_05 | AC | 36 ms
51,968 KB |
testcase_06 | AC | 37 ms
52,480 KB |
testcase_07 | WA | - |
testcase_08 | AC | 36 ms
52,224 KB |
testcase_09 | AC | 37 ms
52,224 KB |
testcase_10 | AC | 35 ms
52,480 KB |
testcase_11 | AC | 36 ms
51,968 KB |
testcase_12 | AC | 37 ms
52,224 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 75 ms
75,656 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 82 ms
76,272 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 403 ms
129,320 KB |
testcase_34 | WA | - |
testcase_35 | AC | 393 ms
130,692 KB |
ソースコード
inf = 10 ** 18 def merge(A, left, mid, right): mx = (inf, 0) 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 Ly == 1: A[k] = R[j] j = j + 1 else: if Rx * (Ly - 1) > Ry * (Lx - 1): 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)