結果

問題 No.1430 Coup de Coupon
ユーザー burita083burita083
提出日時 2021-03-14 15:36:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 955 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 488,456 KB
最終ジャッジ日時 2024-04-23 23:09:09
合計ジャッジ時間 4,118 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
16,384 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 AC 46 ms
11,520 KB
testcase_04 AC 46 ms
12,032 KB
testcase_05 AC 46 ms
11,904 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, C = map(int, input().split())
P = []
for i in range(N):
  p = int(input())
  P.append(p)

TX = [tuple(map(int,input().split())) for i in range(C)]

ans = 0
items = [False] * N
qupons = [False] * C
l = []
for idx, p in enumerate(P):
  for i, (t, x) in enumerate(TX):
    if t == 1:
      l.append((idx, i,  min(x, p)))
    else:
      l.append((idx, i, p-p*(100-x)//100))


buys = []
l.sort(key=lambda x:(-x[2]))
for itemsId, couponId, v in l:
  if items[itemsId] == True:
    continue
  if qupons[couponId] == True:
    continue
  items[itemsId] = True
  qupons[couponId] = True
  buys.append((itemsId, couponId))
for i, p in enumerate(P):
  flag = False
  for itemsId, couponId in buys:
    if itemsId == i:
      flag = True
      if TX[couponId][0] == 1:
        ans += max(p-TX[couponId][1], 0)
        break
      else:
        rate = (100-TX[couponId][1])/100
        ans += p*rate
        break
  if flag == False:
    ans += p
print(int(ans))

0