Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Test {
- static Scanner sc = new Scanner(System.in);
- public static void main(String[] args) {
- int n = sc.nextInt();
- int k = sc.nextInt();
- int points[][] = new int[n][4];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < 4; j++){
- points[i][j] = sc.nextInt();
- }
- }
- topKStudents(n, k, points);
- }
- public static void topKStudents(int n, int k, int[][] points) {
- int totalPoints[] = new int[n];
- for(int i = 0; i < n; i++){
- totalPoints[i] = 0;
- for(int j = 0; j < 4; j++){
- totalPoints[i] += points[i][j];
- }
- }
- Integer temp[] = new Integer[n];
- for(int i = 0; i < n; i++)
- temp[i] = totalPoints[i];
- Arrays.sort(temp, Collections.reverseOrder());
- ArrayList<Integer> topK = new ArrayList<Integer>();
- for(int i=0; i < n; i++){
- if(totalPoints[i] + 100 >= temp[k-1])
- topK.add(i);
- }
- System.out.println(topK.size());
- for(int index : topK){
- System.out.print(index + " ");
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement