https://www.acmicpc.net/problem/31925
문자열
부르트포스 문제이다.
import java.io.File
import java.util.StringTokenizer
// input
private var br = System.`in`.bufferedReader()
// variables
private var N = 0
private data class Student(
val name: String, val rank: Int
) : Comparable<Student> {
override fun compareTo(o: Student): Int {
return rank - o.rank
}
} // End of Student class
fun main() {
val bw = System.out.bufferedWriter()
input()
bw.write(solve())
bw.close()
} // End of main()
private fun solve(): String {
val sb = StringBuilder()
val list = ArrayList<Student>()
repeat(N) {
val st = StringTokenizer(br.readLine());
val name = st.nextToken()
val status = st.nextToken()
val isWinner = st.nextToken()
val rank = st.nextToken().toInt()
val apcRank = st.nextToken().toInt()
if (status == "jaehak" && isWinner == "notyet" && (rank == -1 || rank > 3)) {
list.add(Student(name, apcRank))
}
}
list.sort()
val selectedStudents = list.take(10).map { it.name }.toMutableList()
selectedStudents.sort()
sb.append(selectedStudents.size).append('\n')
selectedStudents.forEach {
sb.append(it).append('\n')
}
return sb.toString()
} // End of solve()
private fun input() {
N = br.readLine().toInt()
} // End of input()