(SPOJ) 8698 - Garçom - 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 bandejas = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
for (int i = 0; i < bandejas; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
int latas = Integer.valueOf(tokenizer.nextToken());
int copos = Integer.valueOf(tokenizer.nextToken());
if (latas > copos) {
soma += copos;
}
}
System.out.println(soma);
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 bandejas = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
for (int i = 0; i < bandejas; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
int latas = Integer.valueOf(tokenizer.nextToken());
int copos = Integer.valueOf(tokenizer.nextToken());
if (latas > copos) {
soma += copos;
}
}
System.out.println(soma);
return;
}
}
Comments
Post a Comment