結果

問題 No.116 門松列(1)
コンテスト
ユーザー ID 21712
提出日時 2024-10-30 14:12:08
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 318 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,583 ms
コンパイル使用メモリ 283,188 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-06 00:10:38
合計ジャッジ時間 11,013 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import . "fmt"

func main() {
	var n,c int
	Scan(&n)
	x:=make([]int,n)
	for i:=range x {
		Scan(&x[i])
		if i>1&&isKadomatsu(x[i-2:]) {
			c++
		}
	}
	Println(c)
}

func isKadomatsu(x []int)bool {
	if len(x)<3 {
		return false
	}
	return x[0]!=x[2]&&
	((x[1]>x[0]&&x[1]>x[2])||
	(x[1]<x[0]&&x[1]<x[2]))
}
0