結果

問題 No.1748 Parking Lot
ユーザー HimaHima
提出日時 2022-07-04 20:22:43
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,668 bytes
コンパイル時間 13,680 ms
コンパイル使用メモリ 211,580 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 04:35:23
合計ジャッジ時間 14,160 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solveHonestly(n, k int) int {
	const INF = 1 << 60
	f := make([]int, n)
	f[k-1] = 1
	ans := 0
	for i := 2; i <= n; i++ {
		d := 0
		found := false
		g := make([]int, n)
		for j := range g {
			g[j] = INF
		}
		for j := 0; j < n; j++ {
			if f[j] > 0 {
				g[j] = 0
				found = true
				d = 0
			} else if found {
				g[j] = Min(g[j], d)
			}
			d++
		}
		d = 0
		found = false
		for j := n - 1; j >= 0; j-- {
			if f[j] > 0 {
				g[j] = 0
				found = true
				d = 0
			} else if found {
				g[j] = Min(g[j], d)
			}
			d++
		}
		idx := -1
		x := 0
		for j := 0; j < n; j++ {
			if x < g[j] {
				idx = j
				x = g[j]
			}
		}
		f[idx] = i
		if i == n {
			ans = idx + 1
		}
		//fmt.Println("i = ", i, " g = ", g)
	}
	//PrintHorizonaly(f)
	return ans
}

func solve(n, k int) int {
	ans := n - 1
	if n-1 == k {
		ans = n
	}
	return ans
}
func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()

	//ans := solveHonestly(n, k)
	ans := solve(n, k)

	PrintInt(ans)
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func PrintInt(x int) {
	defer out.Flush()
	fmt.Fprintln(out, x)
}

func PrintHorizonaly(x []int) {
	defer out.Flush()
	fmt.Fprintf(out, "%d", x[0])
	for i := 1; i < len(x); i++ {
		fmt.Fprintf(out, " %d", x[i])
	}
	fmt.Fprintln(out)
}

func PrintVertically(x []int) {
	defer out.Flush()
	for _, v := range x {
		fmt.Fprintln(out, v)
	}
}

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
0