(SPOJ) 11638 - Maratona - 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 qtePostos = Integer.valueOf(tokenizer.nextToken());
int distanciaCorredor = Integer.valueOf(tokenizer.nextToken());
boolean ok = false;
boolean impossivel = false;
line = br.readLine();
tokenizer = new StringTokenizer(line);
int postoAnterior = 0;
int proxPosto = 0;
for (int i = 0; i < qtePostos; i++) {
proxPosto = Integer.valueOf(tokenizer.nextToken());
if ((proxPosto-postoAnterior) > distanciaCorredor) {
impossivel = true;
}
postoAnterior = proxPosto;
}
proxPosto = 42195;
if ((proxPosto-postoAnterior) > distanciaCorredor) {
impossivel = true;
}
if (impossivel) {
System.out.println("N");
}
else {
System.out.println("S");
}
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 qtePostos = Integer.valueOf(tokenizer.nextToken());
int distanciaCorredor = Integer.valueOf(tokenizer.nextToken());
boolean ok = false;
boolean impossivel = false;
line = br.readLine();
tokenizer = new StringTokenizer(line);
int postoAnterior = 0;
int proxPosto = 0;
for (int i = 0; i < qtePostos; i++) {
proxPosto = Integer.valueOf(tokenizer.nextToken());
if ((proxPosto-postoAnterior) > distanciaCorredor) {
impossivel = true;
}
postoAnterior = proxPosto;
}
proxPosto = 42195;
if ((proxPosto-postoAnterior) > distanciaCorredor) {
impossivel = true;
}
if (impossivel) {
System.out.println("N");
}
else {
System.out.println("S");
}
return;
}
}
Comments
Post a Comment