結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー sotanishysotanishy
提出日時 2021-03-18 22:36:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 866 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 155,092 KB
最終ジャッジ日時 2024-04-28 13:03:16
合計ジャッジ時間 10,767 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,864 KB
testcase_01 AC 42 ms
52,480 KB
testcase_02 AC 40 ms
52,132 KB
testcase_03 AC 39 ms
52,480 KB
testcase_04 AC 40 ms
52,352 KB
testcase_05 AC 40 ms
52,096 KB
testcase_06 WA -
testcase_07 AC 41 ms
52,864 KB
testcase_08 WA -
testcase_09 AC 40 ms
52,596 KB
testcase_10 AC 40 ms
52,096 KB
testcase_11 WA -
testcase_12 AC 42 ms
52,608 KB
testcase_13 AC 41 ms
52,352 KB
testcase_14 AC 41 ms
52,224 KB
testcase_15 WA -
testcase_16 AC 41 ms
52,352 KB
testcase_17 AC 42 ms
52,352 KB
testcase_18 AC 40 ms
52,864 KB
testcase_19 WA -
testcase_20 AC 40 ms
52,096 KB
testcase_21 AC 41 ms
52,608 KB
testcase_22 AC 247 ms
127,112 KB
testcase_23 AC 106 ms
88,648 KB
testcase_24 AC 99 ms
86,740 KB
testcase_25 AC 254 ms
131,508 KB
testcase_26 AC 291 ms
151,512 KB
testcase_27 AC 265 ms
132,792 KB
testcase_28 AC 298 ms
152,784 KB
testcase_29 AC 140 ms
96,980 KB
testcase_30 AC 123 ms
90,108 KB
testcase_31 AC 297 ms
152,116 KB
testcase_32 AC 142 ms
95,084 KB
testcase_33 AC 82 ms
77,080 KB
testcase_34 AC 152 ms
99,324 KB
testcase_35 AC 285 ms
141,796 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
import sys
input = sys.stdin.readline

class Compress:
    def __init__(self, vs):
        self.xs = list(set(vs))
        self.xs.sort()

    def compress(self, x):
        return bisect_left(self.xs, x)

    def decompress(self, i):
        return self.xs[i]

N = int(input())
A = list(map(int, input().split()))
comp = Compress(A)
A = [comp.compress(x) for x in A]
prv = [N - 1] + list(range(N - 1))
nxt = list(range(1, N)) + [0]
idx = [[] for _ in range(N)]
for i, x in enumerate(A):
    idx[x].append(i)
i = N - 1
ans = 0
for x in sorted(list(set(A)), reverse=True):
    M = len(idx[x])
    j = bisect_left(idx[x], i) % M
    for _ in range(M):
        if i != idx[x][j]:
            i = idx[x][j]
            ans += 1
        nxt[prv[i]] = nxt[i]
        prv[nxt[i]] = prv[i]
        i = prv[i]
        j = (j - 1) % M
print(ans)
0