Submission #6515719


Source Code Expand


import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
	func()
	pw.flush()
}

fun func(){

	val (n,t) = listOfInt()

	var ans = 0

	val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()})

	for(i in 1 until n){
		ans+= Math.min(array[i]-array[i-1],t)
	}
	pw.println(ans+t)

}

/**
 * いつもの
 */
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }


/**
 * 配列,リスト関連の便利メソッド
 */

fun max(vararg ints:Int):Int{
	var max = Int.MIN_VALUE
	for (int in ints) {
		max = Math.max(max,int)
	}
	return max
}

fun max(vararg longs:Long):Long{
	var max = Long.MIN_VALUE
	for (long in longs) {
		max = Math.max(max,long)
	}
	return max
}

Submission Info

Submission Time
Task B - 自動ドア
User s103ng
Language Kotlin (1.0.0)
Score 0
Code Size 1051 Byte
Status CE

Compile Error

Main.kt:17:33: error: unresolved reference: MutableList
	val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()})
                                ^
Main.kt:17:48: error: cannot infer a type for this parameter. Please specify it explicitly.
	val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()})
                                               ^
Main.kt:17:48: error: names _, __, ___, ..., are reserved in Kotlin
	val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()})
                                               ^