結果
| 問題 | No.1708 Quality of Contest |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-20 11:39:45 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 477 ms / 2,000 ms |
| + 507µs | |
| コード長 | 1,778 bytes |
| 記録 | |
| コンパイル時間 | 230 ms |
| コンパイル使用メモリ | 96,492 KB |
| 実行使用メモリ | 140,160 KB |
| 最終ジャッジ日時 | 2026-07-20 11:40:04 |
| 合計ジャッジ時間 | 11,423 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
import sys, math
sys.setrecursionlimit(10**8)
sys.set_int_max_str_digits(0)
INF = 1e18
MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def I(): return input().rstrip()
def II(): return int(input().rstrip())
def IS(): return input().rstrip().split()
def MII(): return map(int, input().rstrip().split())
def LI(): return list(input().rstrip())
def TII(): return tuple(map(int, input().rstrip().split()))
def LII(): return list(map(int, input().rstrip().split()))
def LSI(): return list(map(str, input().rstrip().split()))
def GMI(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def kiriage(a, b): return (a+b-1)//b
N, M, X = MII()
genre = [list() for _ in range(M)]
for i in range(N):
a, b = MII()
# a ... quality, b ... genre
b -= 1
genre[b].append(a)
K = II()
C = LII()
# 各問題を解く人数
cnt = [0]*(N + 2)
for c in C:
if c != 0:
cnt[1] += 1
cnt[c + 1] -= 1
for i in range(1, N + 1):
cnt[i + 1] += cnt[i]
que = []
# 問題を解く順を決める
# 各ジャンルの最高問題をqueに入れる
for i in range(M):
if genre[i]:
genre[i].sort()
target = genre[i].pop() + X
heappush(que, (-target, i))
# 一問目から順に割り当てる
ans = 0
for i in range(1, N + 1):
mondai, genreid = heappop(que)
mondai *= -1
# cnt[i] 人解く
ans += mondai * cnt[i]
# そのジャンル、後続がいれば補充する
if genre[genreid]:
target = genre[genreid].pop()
heappush(que, (-target, genreid))
print(ans)