(SPOJ) 10865 - Corrida - 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 qteCompetidores = Integer.valueOf(tokenizer.nextToken());
int qteVoltas = Integer.valueOf(tokenizer.nextToken());
long menor = 1000000000L;
long soma = 0L;
int competidor = 0;
for (int i = 0; i < qteCompetidores; i++) {
soma = 0;
line = br.readLine();
tokenizer = new StringTokenizer(line);
for (int j = 0; j < qteVoltas; j++) {
int tempo = Integer.valueOf(tokenizer.nextToken());
soma += tempo;
}
if (soma < menor) {
menor = soma;
competidor = i+1;
}
}
System.out.println(competidor);
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 qteCompetidores = Integer.valueOf(tokenizer.nextToken());
int qteVoltas = Integer.valueOf(tokenizer.nextToken());
long menor = 1000000000L;
long soma = 0L;
int competidor = 0;
for (int i = 0; i < qteCompetidores; i++) {
soma = 0;
line = br.readLine();
tokenizer = new StringTokenizer(line);
for (int j = 0; j < qteVoltas; j++) {
int tempo = Integer.valueOf(tokenizer.nextToken());
soma += tempo;
}
if (soma < menor) {
menor = soma;
competidor = i+1;
}
}
System.out.println(competidor);
return;
}
}
Comments
Post a Comment