結果

問題 No.1430 Coup de Coupon
ユーザー tcltktcltk
提出日時 2021-06-26 06:31:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,195 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 84,752 KB
最終ジャッジ日時 2023-09-07 13:44:59
合計ジャッジ時間 8,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 193 ms
80,664 KB
testcase_01 AC 188 ms
80,848 KB
testcase_02 AC 193 ms
81,068 KB
testcase_03 AC 206 ms
84,352 KB
testcase_04 AC 207 ms
84,104 KB
testcase_05 AC 207 ms
84,092 KB
testcase_06 AC 209 ms
84,356 KB
testcase_07 AC 219 ms
84,420 KB
testcase_08 AC 217 ms
84,536 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 224 ms
84,752 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 184 ms
80,732 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

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