(UVA) 12403 - Save Setu - Solução

import java.io.*;
import java.util.*;
import java.lang.Math;

class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        Main processando = new Main();
        processando.takeInput();
       
        System.exit(0);
    }
   
    void takeInput() throws NumberFormatException, IOException {
        String line = "";

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        line = br.readLine();
       
        int numOp = Integer.parseInt(line);
       
        int saldo = 0;
        for (int i = 0; i < numOp; i++) {
            line = br.readLine();
           
            if (line.equals("report")) {
                System.out.println(saldo);
            }
            else {
                String[] vetor = line.split(" ");
                saldo += Integer.parseInt(vetor[1]);
            }       
        }
                     
        return;
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução