(SPOJ) 19963 - OBI - 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);
    }

    static int leitor(BufferedReader br) throws NumberFormatException, IOException {
        int n;
        int resp = 0;

        while (true) {
            n = br.read();
            if (n >= '0' && n <= '9') break;
        }
        while (true) {
            resp = resp*10 + n-'0';
            n = br.read();
            if (n < '0' || n > '9') break;
        }

        return resp;
    }

    void processa() throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int numCompetidores = leitor(br);
        int minPontos = leitor(br);
       
        int nota1;
        int nota2;
       
        int contaConvidados = 0;           
        for (int i = 0; i < numCompetidores; i++) {
            nota1 = leitor(br);
            nota2 = leitor(br);
           
            if ((nota1 + nota2) >= minPontos) {
                contaConvidados++;
            }
        }
       
        System.out.println(contaConvidados);             

        return;
    }
}





Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução