結果

問題 No.945 YKC饅頭
ユーザー tamatotamato
提出日時 2019-12-09 22:25:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,076 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 162,364 KB
最終ジャッジ日時 2023-09-05 11:27:53
合計ジャッジ時間 53,507 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,268 KB
testcase_01 AC 77 ms
71,220 KB
testcase_02 AC 89 ms
75,976 KB
testcase_03 AC 104 ms
77,580 KB
testcase_04 AC 81 ms
75,592 KB
testcase_05 AC 92 ms
76,460 KB
testcase_06 AC 102 ms
77,216 KB
testcase_07 AC 95 ms
76,440 KB
testcase_08 AC 83 ms
76,120 KB
testcase_09 AC 91 ms
76,508 KB
testcase_10 AC 97 ms
76,432 KB
testcase_11 AC 89 ms
75,976 KB
testcase_12 AC 99 ms
77,132 KB
testcase_13 AC 104 ms
77,176 KB
testcase_14 AC 105 ms
77,456 KB
testcase_15 AC 77 ms
71,452 KB
testcase_16 AC 85 ms
76,008 KB
testcase_17 AC 87 ms
76,320 KB
testcase_18 AC 97 ms
76,448 KB
testcase_19 AC 88 ms
75,996 KB
testcase_20 AC 85 ms
76,080 KB
testcase_21 AC 79 ms
75,644 KB
testcase_22 AC 105 ms
77,436 KB
testcase_23 AC 107 ms
77,496 KB
testcase_24 AC 106 ms
77,356 KB
testcase_25 AC 107 ms
77,492 KB
testcase_26 AC 102 ms
77,192 KB
testcase_27 AC 85 ms
75,824 KB
testcase_28 AC 84 ms
75,688 KB
testcase_29 AC 71 ms
71,544 KB
testcase_30 AC 77 ms
71,232 KB
testcase_31 AC 218 ms
84,312 KB
testcase_32 AC 389 ms
96,244 KB
testcase_33 AC 633 ms
105,568 KB
testcase_34 AC 907 ms
120,492 KB
testcase_35 AC 1,622 ms
157,332 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 802 ms
121,708 KB
testcase_39 AC 411 ms
98,604 KB
testcase_40 AC 540 ms
104,992 KB
testcase_41 AC 371 ms
90,672 KB
testcase_42 AC 1,194 ms
131,576 KB
testcase_43 WA -
testcase_44 AC 1,199 ms
128,968 KB
testcase_45 WA -
testcase_46 AC 259 ms
87,088 KB
testcase_47 AC 929 ms
120,136 KB
testcase_48 AC 246 ms
87,132 KB
testcase_49 AC 557 ms
101,648 KB
testcase_50 AC 1,309 ms
140,492 KB
testcase_51 AC 1,883 ms
161,204 KB
testcase_52 AC 1,919 ms
162,364 KB
testcase_53 AC 1,977 ms
161,572 KB
testcase_54 AC 1,901 ms
161,776 KB
testcase_55 AC 1,926 ms
162,352 KB
testcase_56 AC 492 ms
105,940 KB
testcase_57 AC 248 ms
105,748 KB
testcase_58 AC 1,530 ms
148,260 KB
testcase_59 AC 1,696 ms
157,792 KB
testcase_60 AC 937 ms
117,488 KB
testcase_61 AC 1,606 ms
144,964 KB
testcase_62 AC 1,549 ms
147,380 KB
testcase_63 AC 220 ms
100,064 KB
testcase_64 AC 1,007 ms
115,128 KB
testcase_65 AC 898 ms
122,864 KB
testcase_66 AC 858 ms
124,676 KB
testcase_67 AC 1,283 ms
130,032 KB
testcase_68 AC 967 ms
116,848 KB
testcase_69 AC 508 ms
116,460 KB
testcase_70 AC 576 ms
115,728 KB
testcase_71 AC 585 ms
115,500 KB
testcase_72 AC 1,140 ms
132,268 KB
testcase_73 AC 1,610 ms
143,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # i+1番目からR番目まで足すとt以上となるような最小のRを返す
    def bisect_plus(self, i, t):
        L = i
        R = self.size
        R_prev = R
        sum_i = self.sum(i)
        while True:
            range_sum = self.sum(R) - sum_i
            if range_sum < t:
                if R == self.size:
                    return self.size + 1
                L, R = R, R_prev
            else:
                R_prev = R
                R = (L + R + 1) // 2
                if R == R_prev:
                    return R

    # L番目からi-1番目まで足すとt以上となるような最小のLを返す
    def bisect_minus(self, i, t):
        L = 1
        R = i
        L_prev = L
        sum_i = self.sum(i - 1)
        while True:
            range_sum = sum_i - self.sum(L - 1)
            if range_sum < t:
                if L == 1:
                    return 0
                L, R = L_prev, L
            else:
                L_prev = L
                L = (L + R) // 2
                if L == L_prev:
                    return L


N, M = map(int, input().split())
q = []
qy = [0] * (M+1)
ans = [0] * 3
bit = Bit(N)
for i in range(1, M+1):
    s, t, y = input().split()
    s = int(s)
    t = int(t)
    if y == 'K':
        qy[i] = 1
    elif y == 'C':
        qy[i] = 2
    q.append((s, 1, i))
    if t+1 <= N:
        q.append((t+1, -1, i))
for i in range(1, N+1):
    q.append((i, 0, 0))

q.sort(key=lambda x: x[0])
for i, flg, j in q:
    if flg == 1:
        bit.add(j, 1)
    elif flg == -1:
        bit.add(j, -1)
    elif flg == 0:
        k = bit.bisect_plus(0, 1)
        if k == N+1:
            continue
        ans[qy[k]] += 1

print(*ans)
0