(SPOJ) 3775 - Fliperama - Solução
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
line = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
int qtePartidas = Integer.valueOf(tokenizer.nextToken());
int tamRanking = Integer.valueOf(tokenizer.nextToken());
ArrayList<Integer> pontuacoes = new ArrayList<Integer>();
for (int i = 0; i < qtePartidas; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
pontuacoes.add(Integer.valueOf(tokenizer.nextToken()));
}
Collections.sort(pontuacoes);
for (int i = qtePartidas-1; i > (qtePartidas-1)-tamRanking; i--) {
System.out.println(pontuacoes.get(i));
}
return;
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
line = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
int qtePartidas = Integer.valueOf(tokenizer.nextToken());
int tamRanking = Integer.valueOf(tokenizer.nextToken());
ArrayList<Integer> pontuacoes = new ArrayList<Integer>();
for (int i = 0; i < qtePartidas; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
pontuacoes.add(Integer.valueOf(tokenizer.nextToken()));
}
Collections.sort(pontuacoes);
for (int i = qtePartidas-1; i > (qtePartidas-1)-tamRanking; i--) {
System.out.println(pontuacoes.get(i));
}
return;
}
}
Comments
Post a Comment