結果

問題 No.78 クジ付きアイスバー
ユーザー javyjavy
提出日時 2015-11-28 09:43:27
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 281 ms / 5,000 ms
コード長 1,992 bytes
コンパイル時間 11,270 ms
コンパイル使用メモリ 438,988 KB
実行使用メモリ 56,976 KB
最終ジャッジ日時 2024-04-30 11:30:07
合計ジャッジ時間 23,057 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 267 ms
56,952 KB
testcase_01 AC 265 ms
56,932 KB
testcase_02 AC 267 ms
56,824 KB
testcase_03 AC 265 ms
56,836 KB
testcase_04 AC 268 ms
56,860 KB
testcase_05 AC 262 ms
56,924 KB
testcase_06 AC 273 ms
56,864 KB
testcase_07 AC 277 ms
56,964 KB
testcase_08 AC 268 ms
56,940 KB
testcase_09 AC 277 ms
56,940 KB
testcase_10 AC 271 ms
56,948 KB
testcase_11 AC 272 ms
56,844 KB
testcase_12 AC 270 ms
56,824 KB
testcase_13 AC 264 ms
56,976 KB
testcase_14 AC 267 ms
56,820 KB
testcase_15 AC 273 ms
56,868 KB
testcase_16 AC 264 ms
56,704 KB
testcase_17 AC 280 ms
56,920 KB
testcase_18 AC 273 ms
56,924 KB
testcase_19 AC 269 ms
56,824 KB
testcase_20 AC 277 ms
56,856 KB
testcase_21 AC 279 ms
56,944 KB
testcase_22 AC 269 ms
56,912 KB
testcase_23 AC 273 ms
56,960 KB
testcase_24 AC 276 ms
56,868 KB
testcase_25 AC 269 ms
56,944 KB
testcase_26 AC 270 ms
56,896 KB
testcase_27 AC 267 ms
56,940 KB
testcase_28 AC 274 ms
56,848 KB
testcase_29 AC 274 ms
56,828 KB
testcase_30 AC 272 ms
56,828 KB
testcase_31 AC 272 ms
56,812 KB
testcase_32 AC 264 ms
56,916 KB
testcase_33 AC 268 ms
56,916 KB
testcase_34 AC 267 ms
56,868 KB
testcase_35 AC 258 ms
56,964 KB
testcase_36 AC 281 ms
56,964 KB
testcase_37 AC 275 ms
56,860 KB
testcase_38 AC 269 ms
56,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:6:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

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
    }

    fun readLineDoubleArray(): List<Double> {
        val str = readLine() as String
        val arrStr = str.split(" ")
        val ret = arrStr.map { it.toDouble() }
        return ret
    }

    fun readLineDouble() : Double {
        val str = readLine() as String
        return str.toDouble()
    }
    val input = readLineIntArray()
    val num = input[0]
    val iceArray = (readLine() as String).toCharArray().map { it.toString().toInt() }
    var sum = 0
    for (item in iceArray) {
        sum += item
    }
    sum -= num
    var needIce = input[1]
    var buyIce = 0
    var moreIce = 0
    for (i in 0..Int.MAX_VALUE) {
        if (moreIce == 0) {
            buyIce++
        } else {
            moreIce--
        }
        moreIce += iceArray[i%num]
        needIce--
        if (needIce <= 0)
            break
        if (i >= num) {
            if (sum >= 0) {
                break
            } else {
                if (((needIce / num) - 2) > 0) {
//                    println(((needIce / num) - 2))
                    buyIce += ((needIce / num) - 2) * (-sum)
                    needIce -= ((needIce / num) - 2) * num
                }
            }
        }
//        println("\t" + needIce)
        if (needIce <= 0)
            break
    }
    println(buyIce)
//    println(sum)
}
0