結果
| 問題 | No.3409 How Many Gift Boxes? |
| コンテスト | |
| ユーザー |
cleantted
|
| 提出日時 | 2025-12-20 14:36:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 145 ms / 2,000 ms |
| コード長 | 652 bytes |
| 記録 | |
| コンパイル時間 | 484 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 103,372 KB |
| 最終ジャッジ日時 | 2025-12-20 14:36:10 |
| 合計ジャッジ時間 | 8,035 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
mod = 10 ** 9 + 7
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
maxT = max(max(A), max(B))
def f():
M = 0
t = 0
i = 0
pb = 0
for b in B:
while i < N and A[i] < b:
t += (A[i] - pb) * (N - i) % mod
t %= mod
pb = A[i]
i += 1
t += (b - pb) * (N - i) % mod
t %= mod
pb = b
M += t
M %= mod
return M
def g():
res = 0
i = 0
for b in B:
while i < N and A[i] < b:
res += A[i]
i += 1
if i < N and A[i] == b:
i += 1
res += b
res += sum(A[i:])
return res % mod
print(g())
print(f())
cleantted