(SPOJ) 19939 - Carnaval - 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 {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        String line = br.readLine();
        StringTokenizer tokenizer = new StringTokenizer(line);
       
        float notas[] = new float[5];
       
        for (int i = 0; i < 5; i++) {
            notas[i] = Float.valueOf(tokenizer.nextToken());
        }
       
        Arrays.sort(notas);
       
        float resultado = 0.0f;
        for (int i = 1; i < 4; i++) {
            resultado += notas[i];
        }

        System.out.printf("%.1f\n", resultado);
           
        return;
    }
   
}


Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução