結果

問題 No.3409 How Many Gift Boxes?
コンテスト
ユーザー titia
提出日時 2025-12-16 03:49:43
言語 PyPy3
(7.3.17)
結果
TLE  
実行時間 -
コード長 385 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 300 ms
コンパイル使用メモリ 82,884 KB
実行使用メモリ 101,616 KB
最終ジャッジ日時 2025-12-16 03:49:48
合計ジャッジ時間 5,072 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5 TLE * 1 -- * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

from collections import Counter

mod=10**9+7

H,W=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ANS=0
for i in range(H):
    for j in range(W):
        ANS+=min(A[i],B[j])

CA=Counter(A)
CB=Counter(B)

ANS2=0

S=set(A)|set(B)

for s in S:
    ANS2+=max(CA[s],CB[s])*s

print(ANS2%mod)
print(ANS%mod)
0