結果

問題 No.482 あなたの名は
ユーザー ygd.ygd.
提出日時 2022-03-21 17:05:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,466 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,764 KB
最終ジャッジ日時 2024-04-17 10:03:53
合計ジャッジ時間 13,028 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 WA -
testcase_08 AC 30 ms
10,880 KB
testcase_09 AC 28 ms
10,752 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 30 ms
10,880 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 29 ms
10,752 KB
testcase_15 AC 749 ms
29,628 KB
testcase_16 AC 720 ms
29,628 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 704 ms
29,628 KB
testcase_20 WA -
testcase_21 AC 725 ms
29,628 KB
testcase_22 AC 731 ms
29,628 KB
testcase_23 AC 736 ms
29,756 KB
testcase_24 WA -
testcase_25 AC 720 ms
29,636 KB
testcase_26 AC 721 ms
29,632 KB
testcase_27 AC 721 ms
29,632 KB
testcase_28 AC 711 ms
29,636 KB
testcase_29 AC 662 ms
29,628 KB
testcase_30 AC 26 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict 
#from collections import deque
#import copy
#import math
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
 
    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)
 
    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)

def main():
    N,K = map(int,input().split())
    D = list(map(int,input().split()))
    Tree = BIT(N)

    inversion_number = 0
    for i in range(N):
        #自分以下で既に出てきた数字(i.e.左側にある数字)を引く。
        inversion_number += i - Tree.to_sum(D[i]) #BITは1-indexだがDも1-index
        Tree.add(D[i],1) #出てきた数字を記録

    if inversion_number > K:
        print('NO')
    elif (inversion_number - K)%2 == 0:
        print('YES')
    else:
        print('NO')

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