結果

問題 No.2770 Coupon Optimization
ユーザー ShirotsumeShirotsume
提出日時 2024-05-31 22:33:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,177 ms / 3,000 ms
コード長 813 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 82,068 KB
実行使用メモリ 186,432 KB
最終ジャッジ日時 2024-05-31 22:34:02
合計ジャッジ時間 14,715 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
66,872 KB
testcase_01 AC 60 ms
66,376 KB
testcase_02 AC 57 ms
66,040 KB
testcase_03 AC 918 ms
115,760 KB
testcase_04 AC 297 ms
144,360 KB
testcase_05 AC 104 ms
100,140 KB
testcase_06 AC 1,135 ms
186,108 KB
testcase_07 AC 622 ms
139,740 KB
testcase_08 AC 1,161 ms
185,916 KB
testcase_09 AC 215 ms
98,752 KB
testcase_10 AC 637 ms
141,536 KB
testcase_11 AC 554 ms
140,712 KB
testcase_12 AC 508 ms
119,792 KB
testcase_13 AC 565 ms
122,516 KB
testcase_14 AC 1,145 ms
186,288 KB
testcase_15 AC 1,142 ms
186,432 KB
testcase_16 AC 1,154 ms
186,024 KB
testcase_17 AC 1,177 ms
186,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
import string

n, m = mi()
a = li()
b = li()
coupon = [0] * 101

for i in range(m):
    coupon[100 - b[i]] += 1
coupon[100] = inf
tako = [deque() for _ in range(101)]
takosum = [0] * 101

a.sort()
ans = 0
for i in range(n): 
    tako[0].appendleft(a[i])
    takosum[0] += a[i]
    for j in range(101):
        if len(tako[j]) <= coupon[j]:
            break
        takosum[j] -= tako[j][-1]
        tako[j + 1].appendleft(tako[j].pop())
        takosum[j + 1] += tako[j + 1][0]
    ans = 0
    for i in range(101):
        ans += takosum[i] * i // 100
    print(ans)
0