結果

問題 No.411 昇順昇順ソート
ユーザー FromBooskaFromBooska
提出日時 2023-10-19 12:15:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 555 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 81,644 KB
実行使用メモリ 75,532 KB
最終ジャッジ日時 2023-10-19 12:15:19
合計ジャッジ時間 5,758 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,392 KB
testcase_01 AC 39 ms
53,392 KB
testcase_02 AC 39 ms
53,392 KB
testcase_03 AC 39 ms
53,392 KB
testcase_04 AC 39 ms
53,392 KB
testcase_05 AC 40 ms
53,392 KB
testcase_06 AC 39 ms
53,392 KB
testcase_07 AC 39 ms
53,392 KB
testcase_08 AC 39 ms
53,392 KB
testcase_09 AC 39 ms
53,392 KB
testcase_10 AC 40 ms
53,392 KB
testcase_11 AC 39 ms
53,392 KB
testcase_12 AC 39 ms
53,392 KB
testcase_13 AC 39 ms
53,392 KB
testcase_14 AC 39 ms
53,392 KB
testcase_15 AC 40 ms
53,392 KB
testcase_16 AC 39 ms
53,392 KB
testcase_17 AC 38 ms
53,392 KB
testcase_18 AC 39 ms
53,392 KB
testcase_19 AC 39 ms
53,392 KB
testcase_20 AC 38 ms
53,392 KB
testcase_21 AC 39 ms
53,392 KB
testcase_22 AC 38 ms
53,392 KB
testcase_23 AC 38 ms
53,392 KB
testcase_24 AC 39 ms
53,392 KB
testcase_25 AC 38 ms
53,392 KB
testcase_26 AC 39 ms
53,392 KB
testcase_27 AC 57 ms
70,364 KB
testcase_28 AC 555 ms
75,420 KB
testcase_29 AC 225 ms
75,372 KB
testcase_30 AC 513 ms
75,516 KB
testcase_31 AC 512 ms
75,532 KB
testcase_32 AC 510 ms
75,472 KB
testcase_33 AC 537 ms
75,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# ビット全探索で前半の昇順リストを作る、残りが後半の昇順リスト
# 後半の第1項が前半の最後項よりも辞書順前ならカウント

N, K = map(int, input().split())
count = 0
for bit in range(1<<N):
    chosen = []
    unchosen = []
    for shift in range(N):
        if bit>>shift&1 == 1:
            chosen.append(shift+1)
        else:
            unchosen.append(shift+1)
    if len(chosen)>0 and len(unchosen)>0 and chosen[-1]>unchosen[0] and chosen[0]==K:
        #print(chosen, unchosen)
        count += 1
print(count)
0