Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*
- var sc: Scanner = Scanner(System.`in`)
- fun main() {
- val n: Int = sc.nextInt()
- val k: Int = sc.nextInt()
- val points = Array(n) { IntArray(4) }
- for (i in 0 until n) {
- for (j in 0..3) {
- points[i][j] = sc.nextInt()
- }
- }
- topKStudents(n, k, points)
- }
- fun topKStudents(n: Int, k: Int, points: Array<IntArray>) {
- val totalPoints = IntArray(n)
- for (i in 0 until n) {
- totalPoints[i] = 0
- for (j in 0..3) {
- totalPoints[i] += points[i][j]
- }
- }
- val temp = IntArray(n)
- for (i in 0 until n)
- temp[i] = totalPoints[i]
- temp.sortDescending()
- val topK: ArrayList<Int> = ArrayList<Int>()
- for (i in 0 until n) {
- if (totalPoints[i] + 100 >= temp[k - 1])
- topK.add(i)
- }
- println(topK.size)
- for (index in topK) {
- print("$index ")
- }
- println()
- }
Add Comment
Please, Sign In to add comment