結果

問題 No.482 あなたの名は
ユーザー はむ吉🐹はむ吉🐹
提出日時 2017-02-10 23:20:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,036 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 98,528 KB
最終ジャッジ日時 2023-08-28 08:54:48
合計ジャッジ時間 7,215 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,884 KB
testcase_01 AC 71 ms
71,240 KB
testcase_02 AC 70 ms
71,096 KB
testcase_03 WA -
testcase_04 AC 69 ms
71,296 KB
testcase_05 WA -
testcase_06 AC 72 ms
71,316 KB
testcase_07 WA -
testcase_08 AC 81 ms
75,792 KB
testcase_09 AC 74 ms
70,896 KB
testcase_10 AC 82 ms
75,576 KB
testcase_11 AC 83 ms
75,868 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 81 ms
75,664 KB
testcase_15 AC 272 ms
98,292 KB
testcase_16 AC 271 ms
98,336 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 267 ms
98,356 KB
testcase_20 WA -
testcase_21 AC 271 ms
97,980 KB
testcase_22 AC 270 ms
98,272 KB
testcase_23 AC 271 ms
98,396 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 273 ms
98,224 KB
testcase_28 AC 265 ms
98,168 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import sys


REC_LIMIT = 10000


# http://www.prefield.com/algorithm/sort/mergecount.html
def inversion_number(xs):
    n = len(xs)
    cnt = 0
    if n > 1:
        bs = xs[:n // 2]
        cs = xs[n // 2:]
        cnt += inversion_number(bs)
        cnt += inversion_number(cs)
        j = 0
        k = 0
        for i in range(n):
            if k == len(cs):
                xs[i] = bs[j]
                j += 1
            elif j == len(bs):
                xs[i] = cs[k]
                k += 1
            elif bs[j] <= cs[k]:
                xs[i] = bs[j]
                j += 1
            else:
                xs[i] = cs[k]
                k += 1
                cnt += n // 2 - j
    return cnt


def judge(n, k, ds):
    inv_n = inversion_number(ds)
    return inv_n % k == 0


def main():
    sys.setrecursionlimit(REC_LIMIT)
    n, k = (int(x) for x in input().split())
    ds = [int(x) for x in input().split()]
    print("YES" if judge(n, k, ds) else "NO")


if __name__ == '__main__':
    main()
0