Submission #6515518
Source Code Expand
import org.jetbrains.annotations.Mutable import java.io.PrintWriter import kotlin.math.min 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+= 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 | 1114 Byte |
Status | CE |
Compile Error
Main.kt:5:15: error: unresolved reference: math import kotlin.math.min ^ Main.kt:20:33: error: unresolved reference: MutableList val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()}) ^ Main.kt:20:48: error: cannot infer a type for this parameter. Please specify it explicitly. val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()}) ^ Main.kt:20:48: error: names _, __, ___, ..., are reserved in Kotlin val array : MutableList<Int> = MutableList(n,{_ -> readLine()!!.toInt()}) ^ Main.kt:23:9: error: unresolved reference: min ans+= min(array[i]-array[i-1],t) ^