結果

問題 No.1430 Coup de Coupon
ユーザー tcltktcltk
提出日時 2021-06-26 06:31:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,195 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 90,240 KB
最終ジャッジ日時 2024-06-25 07:50:48
合計ジャッジ時間 6,370 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """1 2
# 2000
# 1 500
# 2 30
# """
# sys.stdin = io.StringIO(_INPUT)

N, C = map(int, input().split())
P = [int(input()) for _ in range(N)]
Coupons1 = []
Coupons2 = []
for _ in range(C):
    t, x = map(int, input().split())
    if t == 1:
        Coupons1.append(x)
    else:
        Coupons2.append(x)
P.sort(reverse=True)
Coupons1.sort(reverse=True)
Coupons2.sort(reverse=True)

i1 = 0
i2 = 0
cost = 0
for p in P:
    if i1 < len(Coupons1) and i2 < len(Coupons2):
        p1 = max(p - Coupons1[i1], 0)
        p2 = p * (100 - Coupons2[i2]) // 100
        if p1 <= p2:
            cost += p1
            i1 += 1
        else:
            cost += p2
            i2 += 1
    elif i1 < len(Coupons1) and i2 >= len(Coupons2):
        cost += max(p - Coupons1[i1], 0)
        i1 += 1
    elif i2 < len(Coupons2) and i1 >= len(Coupons1):
        cost += p * (100 - Coupons2[i2]) // 100
        i2 += 1
    else:
        cost += p

print(cost)
0