可以用StreamTokenizer实现更快的输入(但是仍然会超时)
调用nextToken()读取一个数据(string或double),会自动以空格和回车作为分割,读一个调一次
调用st.sval获得刚刚读取的String,st.nval获得Double
//挖掘机 https://pintia.cn/problem-sets/994805260223102976/problems/994805289432236032
//1032测试点4超时
import java.io.*
fun main(args: Array<String>) {
//println("蓝翔")
val st = StreamTokenizer(BufferedReader(InputStreamReader(System.`in`)))
val kout = PrintWriter(OutputStreamWriter(System.out))
st.
val count = st.nval.toInt()
var maxScore = 0
var maxScoreSchool = 0
val list = IntArray(count + 1)
for (i in 1..count) {
st.nextToken()
val school = st.nval.toInt()
st.nextToken()
val score = st.nval.toInt()
list[school] += score
}
for (i in list.indices) {
if (list[i] > maxScore) {
maxScoreSchool = i
maxScore = list[i]
}
}
kout.println("$maxScoreSchool $maxScore")
kout.flush()
}
网友评论