Rezultati

Up. imeNalogaJezikRezultatČas oddaje
codingchimpanzees-2019 Kuponi za pice Java 100/100OK 24. apr '19 @ 16:36

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 16/16 94,605 MiB 2,154 s OK
#2 [več] 16/16 53,957 MiB 0,361 s OK
#3 [več] 17/17 89,223 MiB 1,564 s OK
#4 [več] 17/17 88,695 MiB 1,925 s OK
#5 [več] 17/17 101,145 MiB 2,206 s OK
#6 [več] 17/17 90,613 MiB 1,614 s OK

Ocenjevani program (Pica.java):
import java.util.*;

public class Pica {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String[] line1 = sc.nextLine().split(" ");
		int n = Integer.parseInt(line1[0]);
		int stBonov = Integer.parseInt(line1[1]);
		
		ArrayList<Integer> list = new ArrayList<>();
		
		for(int i = 0; i < n; i++) {
			String[] line = sc.nextLine().split(" ");
			int max = Integer.parseInt(line[0]);
			for(String s : line) {
				int a = Integer.parseInt(s);
				if(a > max) {
					max = a;
				}
			}
			list.add(max);
			
		}
		
		Collections.sort(list);

		long sum = 0;
		for(int i = 0; i < stBonov; i++) {
			sum += (long)list.get(i);
		}
		System.out.println(sum);
	}

}
/**
 * 
 * 4 3 5
 * 6
 * 7 8 9 4 */