結果

問題 No.482 あなたの名は
ユーザー tsurukametsurukame
提出日時 2017-03-07 13:53:33
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,854 bytes
コンパイル時間 12,003 ms
コンパイル使用メモリ 214,076 KB
実行使用メモリ 10,168 KB
最終ジャッジ日時 2023-09-05 21:43:23
合計ジャッジ時間 15,824 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

func main() {
	fsc := NewFastScanner()
	N, K := fsc.NextInt(), fsc.NextInt64()
	D := make([]int, 0)
	for i := 0; i < N; i++ {
		D = append(D, fsc.NextInt())
	}
	diff := 0
	for i, val := range D {
		if i+1 != val {
			diff++
		}
	}
	diff = (diff + (diff - 1)) / 2

	if int64(diff) > K {
		fmt.Println("NO")
		return
	}

	K -= int64(diff)
	if K%2 != 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}
0