結果
| 問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
| ユーザー |
maspy
|
| 提出日時 | 2020-04-01 02:38:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 878 ms / 5,000 ms |
| コード長 | 2,517 bytes |
| コンパイル時間 | 224 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 51,316 KB |
| 最終ジャッジ日時 | 2024-09-22 10:37:48 |
| 合計ジャッジ時間 | 26,520 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict
N = int(readline())
L = tuple(map(int, readline().split()))
T = int(readline())
query = readlines()
AC_count = [0] * N
player_score = defaultdict(int)
scores = []
for t, q in enumerate(query):
name, prob = q.split()
if prob == b'?':
continue
p = ord(prob) - ord('A')
lv = L[p]
AC_count[p] += 1
rank = AC_count[p]
player_score[name] += 50 * lv + (250 * lv) // (4 + rank)
x = t - (T + 10) * player_score[name]
scores.append(x)
compress = {x: i for i, x in enumerate(sorted(scores), 1)}
class BinaryIndexedTree():
def __init__(self, seq):
self.size = len(seq)
self.depth = self.size.bit_length()
self.build(seq)
def build(self, seq):
data = seq
size = self.size
for i, x in enumerate(data):
j = i + (i & (-i))
if j < size:
data[j] += data[i]
self.data = data
def __repr__(self):
return self.data.__repr__()
def get_sum(self, i):
data = self.data
s = 0
while i:
s += data[i]
i -= i & -i
return s
def add(self, i, x):
data = self.data
size = self.size
while i < size:
data[i] += x
i += i & -i
def find_kth_element(self, k):
data = self.data
size = self.size
x, sx = 0, 0
dx = 1 << (self.depth)
for i in range(self.depth - 1, -1, -1):
dx = (1 << i)
if x + dx >= size:
continue
y = x + dx
sy = sx + data[y]
if sy < k:
x, sx = y, sy
return x + 1
AC_count = [0] * N
player_score = defaultdict(int)
player_score_c = defaultdict(int)
n_record = 0
bit = BinaryIndexedTree([0] * (T + 10))
for t, q in enumerate(query):
name, prob = q.split()
if prob == b'?':
x = player_score_c[name]
print(bit.get_sum(x))
continue
p = ord(prob) - ord('A')
lv = L[p]
AC_count[p] += 1
rank = AC_count[p]
player_score[name] += 50 * lv + (250 * lv) // (4 + rank)
before = player_score_c[name]
after = compress[t - (T + 10) * player_score[name]]
player_score_c[name] = after
if not before:
n_record += 1
if before:
bit.add(before, -1)
bit.add(after, 1)
maspy