結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-12 14:39:00 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 602 bytes |
| コンパイル時間 | 12,906 ms |
| コンパイル使用メモリ | 222,136 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 01:02:18 |
| 合計ジャッジ時間 | 11,823 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
var n, count int
nums := make([]int, 0, 100)
fmt.Scanln(&n)
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
for _, v := range strings.Split(scanner.Text(), " ") {
i, _ := strconv.Atoi(v)
nums = append(nums, i)
}
for i := 0; i < n-2; i++ {
col := nums[i : i+3]
if (col[1] < col[0] && col[0] < col[2]) || (col[2] < col[0] && col[0] < col[1]) {
count++
continue
}
if (col[0] < col[2] && col[2] < col[1]) || (col[1] < col[2] && col[2] < col[0]) {
count++
}
}
fmt.Println(count)
}