結果

問題 No.411 昇順昇順ソート
ユーザー tsuchinagatsuchinaga
提出日時 2019-05-16 09:49:34
言語 Go
(1.22.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 15,297 ms
コンパイル使用メモリ 205,312 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2023-10-14 14:21:23
合計ジャッジ時間 13,337 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 1 ms
4,372 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 1 ms
4,372 KB
testcase_14 AC 1 ms
4,372 KB
testcase_15 AC 1 ms
4,372 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,372 KB
testcase_20 AC 1 ms
4,368 KB
testcase_21 AC 1 ms
4,368 KB
testcase_22 AC 1 ms
4,372 KB
testcase_23 AC 1 ms
4,372 KB
testcase_24 AC 1 ms
4,368 KB
testcase_25 AC 1 ms
4,368 KB
testcase_26 AC 1 ms
4,372 KB
testcase_27 AC 2 ms
4,372 KB
testcase_28 AC 34 ms
8,356 KB
testcase_29 AC 11 ms
8,248 KB
testcase_30 AC 1 ms
4,372 KB
testcase_31 AC 1 ms
4,368 KB
testcase_32 AC 2 ms
4,372 KB
testcase_33 AC 1 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
)

func main() {
	var n, k int
	_, _ = fmt.Scan(&n, &k)

	nums := make([]int, n)
	for i := range nums {
		nums[i] = i + 1
	}
	nums = remove411(nums, k-1)
	fmt.Println(ascAsc411(nums, k))
}

func remove411(s []int, i int) []int {
	n := make([]int, len(s))
	copy(n, s)
	return append(n[:i], n[i+1:]...)
}

func ascAsc411(nums []int, before int) int {
	cnt := 0
	for i, n := range nums {
		if n < before { // 前の数字より小さな数字でかつ、数列の一番前 = 続く数字が自分より大きい数字しかない場合に昇順昇順になる
			if i == 0 {
				cnt++
			}
		} else {
			cnt += ascAsc411(remove411(nums, i), n)
		}
	}

	return cnt
}
0