結果

問題 No.116 門松列(1)
ユーザー komkomhkomkomh
提出日時 2019-06-05 10:51:11
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 311 ms / 5,000 ms
コード長 849 bytes
コンパイル時間 13,128 ms
コンパイル使用メモリ 414,532 KB
実行使用メモリ 53,180 KB
最終ジャッジ日時 2023-08-13 02:22:20
合計ジャッジ時間 22,358 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
53,180 KB
testcase_01 AC 293 ms
52,600 KB
testcase_02 AC 296 ms
52,712 KB
testcase_03 AC 293 ms
52,716 KB
testcase_04 AC 291 ms
52,676 KB
testcase_05 AC 290 ms
52,600 KB
testcase_06 AC 293 ms
53,064 KB
testcase_07 AC 295 ms
52,804 KB
testcase_08 AC 298 ms
52,788 KB
testcase_09 AC 295 ms
52,764 KB
testcase_10 AC 293 ms
52,636 KB
testcase_11 AC 311 ms
52,972 KB
testcase_12 AC 296 ms
52,648 KB
testcase_13 AC 292 ms
53,008 KB
testcase_14 AC 297 ms
52,824 KB
testcase_15 AC 299 ms
52,832 KB
testcase_16 AC 302 ms
52,800 KB
testcase_17 AC 302 ms
52,928 KB
testcase_18 AC 300 ms
52,732 KB
testcase_19 AC 296 ms
52,752 KB
testcase_20 AC 303 ms
52,584 KB
testcase_21 AC 305 ms
52,636 KB
testcase_22 AC 299 ms
52,832 KB
testcase_23 AC 306 ms
52,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:4:9: warning: variable 'N' is never used
    val N = readLine()!!.toInt()
        ^

ソースコード

diff #

package yukicoder

fun main() {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)

    var count = 0
    for (index in (1 until A.size - 1)) {
        // 門松を生成する
        val kadomatsu = Triple(A[index - 1], A[index], A[index + 1])

        // 同じ高さがない事
        if (kadomatsu.first == kadomatsu.second
            || kadomatsu.second == kadomatsu.third
            || kadomatsu.first == kadomatsu.third
        ) {
            continue
        }

        // 真ん中の高さが2番目でない事
        if (kadomatsu.first > kadomatsu.second && kadomatsu.second > kadomatsu.third) {
            continue
        }
        if (kadomatsu.first < kadomatsu.second && kadomatsu.second < kadomatsu.third) {
            continue
        }
        count++
    }

    print("${count}")
}
0