結果
問題 | No.2770 Coupon Optimization |
ユーザー |
👑 ![]() |
提出日時 | 2024-05-10 22:25:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 763 ms / 3,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 208,616 KB |
最終ジャッジ日時 | 2024-12-20 06:13:15 |
合計ジャッジ時間 | 9,460 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
from collections import deque, Countern, m = map(int, input().split())aa = list(map(int,input().split()))bb = list(map(int,input().split()))aa = [a//100 for a in aa]aa.sort()cb = Counter(100-b for b in bb)if len(bb) < len(aa):cb[100] = len(aa)-len(bb)memo = [deque(maxlen=cb[v]) for v in range(101)]res = 0for a in aa:for i,l in enumerate(memo):if l.maxlen == 0:continueif len(l) == l.maxlen:x = l.popleft()l.append(a)res += (a-x) * ia = xelse:l.append(a)res += a*ibreakprint(res)