結果

問題 No.482 あなたの名は
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-07 10:15:37
言語 Go
(1.21.3)
結果
TLE  
実行時間 -
コード長 624 bytes
コンパイル時間 11,591 ms
コンパイル使用メモリ 214,312 KB
実行使用メモリ 11,484 KB
最終ジャッジ日時 2023-09-05 19:20:52
合計ジャッジ時間 15,828 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, k int
	_, _ = fmt.Scan(&n, &k)
	l := make([]int, n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := range l {
		sc.Scan()
		l[i], _ = strconv.Atoi(sc.Text())
	}

	// sort.Slice(l, func(i, j int) bool {
	// 	if l[i] < l[j] {
	// 		k--
	// 		return true
	// 	}
	// 	return false
	// })
	for i := 0; i < n; i++ {
		if i+1 != l[i] {
			for j := i + 1; j < n; j++ {
				if l[j] == i+1 {
					l[i], l[j] = l[j], l[i]
				}
			}
			k--
		}
	}

	if k >= 0 && k%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
0