結果
問題 | No.482 あなたの名は |
ユーザー |
![]() |
提出日時 | 2017-02-10 23:17:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,043 bytes |
コンパイル時間 | 379 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 97,536 KB |
最終ジャッジ日時 | 2024-12-29 04:27:06 |
合計ジャッジ時間 | 5,632 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 15 |
ソースコード
#!/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 // 2) % 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()