結果

問題 No.116 門松列(1)
ユーザー komkomhkomkomh
提出日時 2019-06-05 10:51:11
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 337 ms / 5,000 ms
コード長 849 bytes
コンパイル時間 13,687 ms
コンパイル使用メモリ 439,704 KB
実行使用メモリ 57,136 KB
最終ジャッジ日時 2024-04-30 20:50:28
合計ジャッジ時間 21,941 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 333 ms
57,012 KB
testcase_01 AC 323 ms
56,960 KB
testcase_02 AC 323 ms
57,108 KB
testcase_03 AC 324 ms
56,888 KB
testcase_04 AC 323 ms
57,040 KB
testcase_05 AC 323 ms
56,872 KB
testcase_06 AC 319 ms
56,848 KB
testcase_07 AC 325 ms
56,896 KB
testcase_08 AC 325 ms
56,856 KB
testcase_09 AC 323 ms
56,992 KB
testcase_10 AC 323 ms
56,924 KB
testcase_11 AC 324 ms
56,736 KB
testcase_12 AC 325 ms
56,992 KB
testcase_13 AC 328 ms
56,880 KB
testcase_14 AC 331 ms
57,044 KB
testcase_15 AC 324 ms
56,920 KB
testcase_16 AC 327 ms
57,044 KB
testcase_17 AC 324 ms
56,924 KB
testcase_18 AC 326 ms
57,000 KB
testcase_19 AC 324 ms
56,864 KB
testcase_20 AC 328 ms
57,084 KB
testcase_21 AC 337 ms
57,136 KB
testcase_22 AC 324 ms
56,952 KB
testcase_23 AC 330 ms
57,028 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