結果

問題 No.78 クジ付きアイスバー
ユーザー javyjavy
提出日時 2015-11-28 09:31:12
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,993 bytes
コンパイル時間 13,897 ms
コンパイル使用メモリ 445,504 KB
実行使用メモリ 57,072 KB
最終ジャッジ日時 2024-04-30 11:26:21
合計ジャッジ時間 27,749 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 320 ms
56,900 KB
testcase_01 AC 318 ms
56,936 KB
testcase_02 AC 315 ms
56,860 KB
testcase_03 AC 316 ms
56,820 KB
testcase_04 AC 316 ms
56,820 KB
testcase_05 AC 313 ms
56,912 KB
testcase_06 AC 316 ms
57,068 KB
testcase_07 AC 314 ms
56,912 KB
testcase_08 AC 310 ms
56,932 KB
testcase_09 AC 310 ms
56,800 KB
testcase_10 AC 311 ms
56,908 KB
testcase_11 AC 313 ms
56,800 KB
testcase_12 AC 316 ms
56,852 KB
testcase_13 AC 312 ms
56,952 KB
testcase_14 AC 307 ms
56,836 KB
testcase_15 AC 309 ms
56,808 KB
testcase_16 AC 319 ms
56,864 KB
testcase_17 AC 318 ms
56,856 KB
testcase_18 AC 313 ms
56,908 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 319 ms
56,804 KB
testcase_24 AC 315 ms
56,816 KB
testcase_25 AC 324 ms
56,928 KB
testcase_26 AC 318 ms
56,944 KB
testcase_27 AC 318 ms
56,820 KB
testcase_28 AC 325 ms
56,900 KB
testcase_29 AC 319 ms
56,928 KB
testcase_30 AC 321 ms
56,872 KB
testcase_31 AC 321 ms
56,768 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 318 ms
56,924 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 / (-sum)) - 2))
                    buyIce += ((needIce / (-sum)) - 2) * num
                    needIce -= ((needIce / num) - 2) * num
                }
            }
        }
//        println("\t" + needIce)
        if (needIce <= 0)
            break
    }
    println(buyIce)
//    println(sum)
}
0