結果

問題 No.178 美しいWhitespace (1)
ユーザー javyjavy
提出日時 2015-11-12 11:48:36
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 1,549 bytes
コンパイル時間 15,113 ms
コンパイル使用メモリ 424,828 KB
実行使用メモリ 53,736 KB
最終ジャッジ日時 2023-08-12 14:40:05
合計ジャッジ時間 24,801 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
53,020 KB
testcase_01 AC 297 ms
52,756 KB
testcase_02 AC 296 ms
52,884 KB
testcase_03 AC 295 ms
52,976 KB
testcase_04 AC 340 ms
53,188 KB
testcase_05 AC 336 ms
53,648 KB
testcase_06 AC 337 ms
53,084 KB
testcase_07 AC 296 ms
52,988 KB
testcase_08 AC 338 ms
53,296 KB
testcase_09 AC 341 ms
53,672 KB
testcase_10 AC 341 ms
53,456 KB
testcase_11 AC 296 ms
53,080 KB
testcase_12 AC 298 ms
52,972 KB
testcase_13 AC 343 ms
53,196 KB
testcase_14 AC 342 ms
53,072 KB
testcase_15 AC 343 ms
53,736 KB
testcase_16 AC 339 ms
53,220 KB
testcase_17 AC 339 ms
53,128 KB
testcase_18 AC 297 ms
52,724 KB
testcase_19 AC 335 ms
53,212 KB
testcase_20 AC 290 ms
52,880 KB
testcase_21 AC 338 ms
53,152 KB
testcase_22 AC 324 ms
53,128 KB
testcase_23 AC 335 ms
53,216 KB
testcase_24 AC 336 ms
53,188 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:6:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:29:33: warning: no cast needed
    var countSpace = 0.toLong() as Long
                                ^

ソースコード

diff #

package Yukicoder

/**
 * Created by hichikawa on 2015/11/12.
 */
fun main(args: Array<String>) {
    fun readLineLongArray() : List<Long> {
        val str = readLine() as String
        val arrStr = str.split(" ")
        val ret = arrStr.map { it.toLong() }
        return ret
    }
    fun readLineLong() : Long {
        val str = readLine() as String
        return str.toLong()
    }
    fun readLineInt() : Int {
        val str = readLine() as String
        return str.toInt()
    }
    fun readLineIntArray() : List<Int> {
        val str = readLine() as String
        val arrStr = str.split(" ")
        val ret = arrStr.map { it.toInt() }
        return ret
    }

    val num = readLineInt()
    var countSpace = 0.toLong() as Long
    var maxNum = Integer.MIN_VALUE
    for (i in 0..(num-1)) {
        val inputArrInt = readLineIntArray()
        val lenLine = inputArrInt[0] + inputArrInt[1] * 4
        if (maxNum == Integer.MIN_VALUE) {
            maxNum = lenLine
        } else if (maxNum == lenLine) {
        } else if (maxNum > lenLine) {
            if (maxNum % 2 == lenLine % 2) {
                countSpace += ((maxNum - lenLine) / 2).toLong()
            } else {
                println(-1)
                return
            }
        } else {
            if (maxNum % 2 == lenLine % 2) {
                countSpace += ((lenLine - maxNum) * i / 2).toLong()
                maxNum = lenLine
            } else {
                println(-1)
                return
            }
        }
    }
    println(countSpace)
}
0