結果
問題 | No.2770 Coupon Optimization |
ユーザー | 👑 hahho |
提出日時 | 2024-05-10 22:25:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 674 ms / 3,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 82,768 KB |
実行使用メモリ | 208,464 KB |
最終ジャッジ日時 | 2024-05-10 22:25:34 |
合計ジャッジ時間 | 8,810 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
55,240 KB |
testcase_01 | AC | 40 ms
54,560 KB |
testcase_02 | AC | 50 ms
54,396 KB |
testcase_03 | AC | 232 ms
104,168 KB |
testcase_04 | AC | 186 ms
132,588 KB |
testcase_05 | AC | 87 ms
104,456 KB |
testcase_06 | AC | 505 ms
198,372 KB |
testcase_07 | AC | 256 ms
110,228 KB |
testcase_08 | AC | 636 ms
197,856 KB |
testcase_09 | AC | 128 ms
97,512 KB |
testcase_10 | AC | 405 ms
138,892 KB |
testcase_11 | AC | 307 ms
140,508 KB |
testcase_12 | AC | 301 ms
126,472 KB |
testcase_13 | AC | 338 ms
124,892 KB |
testcase_14 | AC | 630 ms
197,444 KB |
testcase_15 | AC | 661 ms
207,828 KB |
testcase_16 | AC | 674 ms
208,464 KB |
testcase_17 | AC | 636 ms
197,216 KB |
ソースコード
from collections import deque, Counter n, 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 = 0 for a in aa: for i,l in enumerate(memo): if l.maxlen == 0: continue if len(l) == l.maxlen: x = l.popleft() l.append(a) res += (a-x) * i a = x else: l.append(a) res += a*i break print(res)