結果

問題 No.1170 Never Want to Walk
ユーザー Kiri8128Kiri8128
提出日時 2020-08-14 23:01:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 103,812 KB
最終ジャッジ日時 2024-04-18 22:51:32
合計ジャッジ時間 6,754 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 37 ms
52,992 KB
testcase_02 AC 43 ms
52,352 KB
testcase_03 AC 41 ms
52,584 KB
testcase_04 AC 37 ms
52,992 KB
testcase_05 AC 43 ms
52,864 KB
testcase_06 AC 42 ms
52,608 KB
testcase_07 AC 42 ms
52,096 KB
testcase_08 AC 43 ms
52,352 KB
testcase_09 AC 42 ms
52,480 KB
testcase_10 AC 41 ms
52,224 KB
testcase_11 AC 42 ms
52,352 KB
testcase_12 AC 62 ms
66,816 KB
testcase_13 AC 78 ms
74,696 KB
testcase_14 AC 69 ms
72,192 KB
testcase_15 AC 62 ms
68,480 KB
testcase_16 AC 65 ms
69,120 KB
testcase_17 AC 75 ms
74,368 KB
testcase_18 AC 60 ms
66,944 KB
testcase_19 AC 60 ms
69,248 KB
testcase_20 AC 74 ms
76,176 KB
testcase_21 AC 59 ms
67,712 KB
testcase_22 AC 67 ms
69,504 KB
testcase_23 AC 63 ms
66,916 KB
testcase_24 AC 60 ms
66,432 KB
testcase_25 AC 58 ms
66,944 KB
testcase_26 AC 56 ms
66,816 KB
testcase_27 AC 338 ms
98,448 KB
testcase_28 AC 376 ms
98,560 KB
testcase_29 AC 333 ms
98,872 KB
testcase_30 AC 303 ms
98,560 KB
testcase_31 AC 312 ms
98,824 KB
testcase_32 AC 163 ms
98,560 KB
testcase_33 AC 220 ms
98,684 KB
testcase_34 AC 163 ms
98,832 KB
testcase_35 AC 219 ms
98,368 KB
testcase_36 AC 224 ms
98,720 KB
testcase_37 AC 187 ms
98,816 KB
testcase_38 AC 206 ms
103,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right as br
def par(a):
    L = []
    while P[a] >= 0:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    if par(a) != par(b):
        if P[par(b)] >= P[par(a)]:
            if P[par(b)] == P[par(a)]: P[par(a)] -= 1
            P[par(b)] = par(a)
        else:
            P[par(a)] = par(b)

N, A, B = map(int, input().split())
P = [-1 for i in range(N)]
X = [int(a) for a in input().split()]
done = [0] * N
i = 0
for i in range(N):
    if done[i]: continue
    done[i] = 1
    j = br(X, X[i] + B) - 1
    jma = jmi = j
    while done[j] == 0 and X[j] >= X[i] + A:
        unite(i, j)
        done[j] = 1
        jmi = j
        j -= 1
    done[jma] = 0
    done[jmi] = 0

cnt = [0] * N
for i in range(N):
    cnt[par(i)] += 1
print(*[cnt[par(i)] for i in range(N)], sep = "\n")
0