結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー convexineqconvexineq
提出日時 2021-02-09 06:04:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 750 ms / 5,000 ms
コード長 1,651 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 86,524 KB
実行使用メモリ 131,136 KB
最終ジャッジ日時 2023-09-20 16:59:07
合計ジャッジ時間 26,696 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,692 KB
testcase_01 AC 92 ms
71,424 KB
testcase_02 AC 92 ms
71,532 KB
testcase_03 AC 122 ms
76,932 KB
testcase_04 AC 118 ms
77,068 KB
testcase_05 AC 127 ms
77,092 KB
testcase_06 AC 114 ms
77,264 KB
testcase_07 AC 126 ms
77,068 KB
testcase_08 AC 116 ms
77,072 KB
testcase_09 AC 118 ms
77,288 KB
testcase_10 AC 113 ms
76,836 KB
testcase_11 AC 115 ms
77,064 KB
testcase_12 AC 730 ms
121,436 KB
testcase_13 AC 671 ms
121,180 KB
testcase_14 AC 612 ms
108,652 KB
testcase_15 AC 700 ms
131,136 KB
testcase_16 AC 655 ms
118,012 KB
testcase_17 AC 651 ms
118,176 KB
testcase_18 AC 750 ms
122,844 KB
testcase_19 AC 629 ms
109,088 KB
testcase_20 AC 604 ms
109,452 KB
testcase_21 AC 669 ms
121,000 KB
testcase_22 AC 670 ms
121,296 KB
testcase_23 AC 719 ms
123,384 KB
testcase_24 AC 629 ms
114,132 KB
testcase_25 AC 664 ms
109,700 KB
testcase_26 AC 589 ms
93,784 KB
testcase_27 AC 652 ms
121,540 KB
testcase_28 AC 638 ms
120,128 KB
testcase_29 AC 598 ms
107,824 KB
testcase_30 AC 694 ms
130,816 KB
testcase_31 AC 723 ms
122,796 KB
testcase_32 AC 612 ms
106,856 KB
testcase_33 AC 626 ms
111,628 KB
testcase_34 AC 652 ms
110,656 KB
testcase_35 AC 725 ms
123,376 KB
testcase_36 AC 661 ms
110,648 KB
testcase_37 AC 368 ms
122,160 KB
testcase_38 AC 433 ms
98,692 KB
testcase_39 AC 406 ms
98,692 KB
testcase_40 AC 404 ms
98,692 KB
testcase_41 AC 419 ms
108,204 KB
testcase_42 AC 424 ms
108,088 KB
testcase_43 AC 596 ms
101,648 KB
testcase_44 AC 563 ms
119,216 KB
testcase_45 AC 376 ms
122,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class BIT_dinamic: #0-indexed
    def __init__(self, n):
        self.tree = {}
        self.MAX = 1<<(n+1).bit_length()
    def get_sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            if i in self.tree:
                s += self.tree[i]
            i -= i & -i
        return s
    def query(self,l,r): #a_l + ... + a_r 閉区間
        return self.get_sum(r) - self.get_sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= self.MAX:
            if i in self.tree:
                self.tree[i] += x
            else:
                self.tree[i] = x
            i += i & -i
    def bisect_left(self,w):
        #和が w 以上になる最小の index
        #w が存在しない場合 -1 を返す
        if w <= 0: return 0
        x,k = 0,self.MAX
        while k:
            k >>= 1
            if x+k not in self.tree:
                x += k
            elif self.tree[x+k] < w:
                w -= self.tree[x+k]
                x += k
        return x if x!=self.MAX-1 else -1

def f(n,k): return 50*n+500*n//(8+2*k)

n = int(input())
*a, = map(int,input().split())
T = int(input())

from collections import defaultdict
num = [0]*n
points = defaultdict(int)
last = defaultdict(int)
bit = BIT_dinamic(15601*100000)
for t in range(T):
    s,p = input().split()
    val = points[s]*100000 + (T-1-last[s])
    if p == "?":
        x = bit.get_sum(val)
        print(len(last)-x+1)

    else:
        if points[s]: bit.add(val,-1)
        p = ord(p)-65
        num[p] += 1
        points[s] += f(a[p],num[p])
        last[s] = t
        bit.add(points[s]*100000+(T-1-last[s]),1)
0