From f811d6b0a64c2055140a6169bccb0ab5f63a1523 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Sun, 29 Sep 2024 12:33:25 -0300 Subject: [PATCH] =?UTF-8?q?Solve=20Frota=20de=20T=C3=A1xi=20in=20python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solutions/beecrowd/2295/2295.py | 8 + solutions/beecrowd/2295/generate_in.sh | 40 ++++ solutions/beecrowd/2295/in.txt | 301 +++++++++++++++++++++++++ solutions/beecrowd/2295/out.txt | 301 +++++++++++++++++++++++++ solutions/beecrowd/2295/problem.md | 40 ++++ solutions/beecrowd/2295/tags.txt | 1 + 6 files changed, 691 insertions(+) create mode 100644 solutions/beecrowd/2295/2295.py create mode 100755 solutions/beecrowd/2295/generate_in.sh create mode 100644 solutions/beecrowd/2295/in.txt create mode 100644 solutions/beecrowd/2295/out.txt create mode 100644 solutions/beecrowd/2295/problem.md create mode 100644 solutions/beecrowd/2295/tags.txt diff --git a/solutions/beecrowd/2295/2295.py b/solutions/beecrowd/2295/2295.py new file mode 100644 index 00000000..b60bbcc8 --- /dev/null +++ b/solutions/beecrowd/2295/2295.py @@ -0,0 +1,8 @@ +import sys + +for line in sys.stdin: + a_price, g_price, a_distance, g_distance = map(float, line.split()) + if a_distance / a_price > g_distance / g_price: + print('A') + else: + print('G') diff --git a/solutions/beecrowd/2295/generate_in.sh b/solutions/beecrowd/2295/generate_in.sh new file mode 100755 index 00000000..298e9c5d --- /dev/null +++ b/solutions/beecrowd/2295/generate_in.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -euo pipefail + +TESTCASES=300 +MAX_FUEL=10 +MAX_DISTANCE=20 +CURRENT_PATH=$( dirname -- "${BASH_SOURCE[0]}" ) + +for i in $(seq "${TESTCASES}"); do + if [[ $((RANDOM % 1000)) -eq 0 ]]; then + alcohol_price="${MAX_FUEL}.00" + else + alcohol_price="$((RANDOM % MAX_FUEL)).$((RANDOM % 10))$((RANDOM % 10))" + fi + if [[ $(echo "${alcohol_price} > 9.00" | bc -l) -eq 1 ]]; then + gas_price="10.00" + else + gas_price="$((RANDOM % MAX_FUEL)).$((RANDOM % 10))$((RANDOM % 10))" + while [[ $(echo "${gas_price} < ${alcohol_price}" | bc -l) -eq 1 ]]; do + gas_price="$((RANDOM % MAX_FUEL)).$((RANDOM % 10))$((RANDOM % 10))" + done + fi + + if [[ $((RANDOM % 2000)) -eq 0 ]]; then + alcohol_distance="${MAX_DISTANCE}.00" + else + alcohol_distance="$((RANDOM % MAX_DISTANCE)).$((RANDOM % 10))$((RANDOM % 10))" + fi + if [[ $(echo "${alcohol_distance} > 19.00" | bc -l) -eq 1 ]]; then + gas_distance="${MAX_DISTANCE}.00" + else + gas_distance="$((RANDOM % MAX_DISTANCE)).$((RANDOM % 10))$((RANDOM % 10))" + while [[ $(echo "${gas_distance} < ${alcohol_distance}" | bc -l) -eq 1 ]]; do + gas_distance="$((RANDOM % MAX_DISTANCE)).$((RANDOM % 10))$((RANDOM % 10))" + done + fi + + echo "${alcohol_price} ${gas_price} ${alcohol_distance} ${gas_distance}" > "${CURRENT_PATH}/in-$(printf "%03d" "${i}")".txt +done diff --git a/solutions/beecrowd/2295/in.txt b/solutions/beecrowd/2295/in.txt new file mode 100644 index 00000000..b81d25c0 --- /dev/null +++ b/solutions/beecrowd/2295/in.txt @@ -0,0 +1,301 @@ +0.77 4.73 13.53 14.21 +7.33 7.35 12.53 16.00 +3.11 8.04 5.78 17.29 +0.83 5.46 15.11 16.04 +4.96 8.76 8.34 16.81 +4.65 8.48 6.86 14.02 +8.31 9.02 16.86 19.22 +6.62 8.87 8.63 14.77 +1.65 5.82 5.39 18.41 +4.01 9.20 1.46 9.79 +7.02 9.71 8.89 18.44 +1.75 7.11 12.34 19.56 +2.65 9.14 13.62 15.50 +3.54 5.50 18.16 18.34 +8.24 9.09 5.87 11.93 +8.25 9.00 3.07 19.20 +5.55 9.80 7.15 10.38 +1.75 6.70 17.18 19.57 +9.40 10.00 11.68 18.59 +3.57 6.94 18.04 19.04 +8.88 9.30 7.26 18.99 +4.29 7.59 7.63 18.65 +7.43 8.58 10.22 12.82 +1.99 7.03 3.33 3.71 +3.35 9.83 7.18 14.77 +8.93 9.11 8.89 19.73 +7.62 8.51 17.10 18.17 +9.26 10.00 4.34 13.22 +5.13 6.61 9.49 14.95 +0.40 8.13 13.88 16.19 +7.35 8.69 17.73 18.50 +0.78 6.85 12.98 15.78 +0.80 6.02 8.57 10.34 +6.12 8.83 2.51 14.29 +7.92 8.56 1.92 11.74 +3.79 4.92 2.97 5.29 +6.92 7.91 7.04 13.69 +7.85 8.29 0.43 7.76 +2.48 4.76 4.15 14.10 +6.71 7.93 1.22 6.41 +8.85 9.56 13.70 14.11 +2.47 8.12 15.78 16.79 +1.76 1.79 16.52 17.06 +1.53 3.25 5.13 17.75 +1.05 4.65 9.91 17.12 +3.57 7.63 10.60 13.78 +8.61 9.32 7.97 17.17 +7.66 9.58 11.45 14.47 +1.42 2.76 17.57 18.76 +7.21 7.69 0.89 11.29 +8.04 8.30 15.52 17.78 +9.12 10.00 6.13 6.77 +6.51 9.75 7.67 8.42 +8.44 9.71 9.76 12.37 +1.98 5.27 5.61 9.87 +9.57 10.00 18.02 18.76 +6.92 8.00 2.66 16.13 +8.82 8.96 14.75 17.02 +2.17 5.37 2.55 10.29 +1.48 1.49 0.18 17.13 +9.14 10.00 17.42 19.48 +7.90 9.76 18.21 18.61 +4.63 6.99 2.79 12.80 +9.53 10.00 15.54 17.80 +6.61 9.13 10.95 16.34 +6.54 7.48 11.13 12.28 +1.11 9.64 5.92 6.18 +8.13 9.97 13.15 13.75 +1.46 8.83 8.22 11.71 +0.35 6.48 12.30 16.40 +7.22 9.15 17.63 19.62 +8.99 9.36 11.63 14.12 +5.00 8.47 12.91 18.67 +7.85 9.78 13.29 16.87 +5.28 5.30 2.52 5.07 +4.25 5.29 15.73 18.64 +6.66 7.70 7.91 9.36 +4.05 6.55 10.44 17.69 +9.25 10.00 13.13 16.09 +9.73 10.00 7.86 16.18 +8.88 9.66 1.05 3.23 +9.14 10.00 10.28 19.56 +7.34 7.98 10.97 18.96 +8.03 9.57 13.67 19.69 +9.35 10.00 0.98 10.35 +2.16 5.16 2.56 12.59 +1.33 1.90 18.67 19.85 +3.88 5.18 10.70 15.30 +4.79 8.61 5.04 12.69 +2.34 2.80 12.67 18.49 +7.56 7.73 9.57 15.73 +1.17 2.20 18.48 19.37 +3.91 5.06 1.23 18.50 +6.83 8.80 8.93 11.87 +5.91 9.71 15.65 16.69 +7.74 9.70 1.64 17.97 +8.98 9.49 10.60 11.46 +9.74 10.00 6.51 6.87 +9.94 10.00 7.69 15.45 +7.65 9.15 15.36 19.33 +8.17 8.93 1.02 11.14 +0.64 2.48 6.13 16.27 +4.55 9.10 3.14 4.35 +4.52 7.91 16.68 17.68 +7.34 9.79 5.88 17.09 +8.62 9.63 16.14 17.84 +0.64 1.35 10.73 10.90 +8.14 9.79 4.35 12.90 +5.08 9.29 1.92 10.19 +5.45 6.53 9.19 11.27 +6.34 7.66 13.30 14.67 +6.98 8.24 0.93 15.97 +0.62 2.11 0.25 18.76 +5.08 7.25 14.01 16.10 +2.93 4.09 4.13 6.80 +8.78 9.35 19.69 20.00 +6.51 6.99 4.83 18.96 +2.39 3.87 8.15 8.56 +2.35 3.02 15.83 18.17 +6.95 9.15 2.83 4.66 +6.89 9.77 16.96 17.98 +9.88 10.00 4.54 7.87 +1.94 6.78 7.71 14.94 +9.05 10.00 2.52 17.29 +6.95 8.12 7.80 13.21 +1.34 7.33 11.39 18.38 +7.06 9.32 10.65 14.48 +2.91 5.32 0.79 17.44 +8.22 8.87 14.59 17.25 +6.17 6.30 19.75 20.00 +6.30 6.73 7.36 7.40 +8.99 9.96 15.42 15.65 +0.57 9.78 4.69 4.81 +5.80 5.93 9.76 19.15 +0.33 3.86 15.29 16.99 +2.93 5.78 12.36 19.29 +2.04 6.66 15.92 16.72 +5.08 9.23 1.32 8.22 +7.10 9.82 15.81 17.79 +6.13 9.30 4.58 6.42 +2.60 3.20 11.76 15.77 +9.70 10.00 4.62 14.31 +4.10 7.53 13.52 17.76 +7.52 9.82 16.65 19.53 +2.78 8.67 1.65 11.77 +7.48 9.02 1.28 13.89 +9.64 10.00 13.21 15.82 +2.60 4.71 0.71 0.74 +1.33 7.44 10.50 18.88 +9.91 10.00 13.21 16.35 +4.14 8.77 2.61 6.74 +9.59 10.00 4.16 9.63 +7.77 9.97 6.91 12.85 +3.03 7.07 18.78 19.48 +1.84 9.89 0.65 5.51 +9.96 10.00 14.10 17.79 +6.47 9.91 14.07 16.48 +4.75 8.30 16.50 16.64 +1.37 6.53 7.94 12.08 +5.08 6.72 7.04 14.81 +9.80 10.00 0.35 4.58 +6.65 7.84 1.45 13.81 +8.36 8.89 5.23 8.40 +3.44 8.61 2.37 7.60 +4.87 7.64 17.49 17.91 +5.51 9.75 11.07 19.29 +9.20 10.00 6.06 12.13 +9.65 10.00 15.96 16.26 +5.29 5.30 5.97 14.01 +9.31 10.00 13.62 14.29 +7.49 9.62 19.30 20.00 +8.88 9.51 0.56 17.95 +2.82 7.92 10.43 15.18 +1.92 9.05 3.23 11.36 +9.23 10.00 2.14 17.12 +6.80 8.69 6.36 10.08 +4.83 4.86 0.31 3.39 +8.07 9.33 19.30 20.00 +3.35 5.59 6.00 7.14 +4.23 6.06 17.12 18.61 +2.31 6.28 0.02 0.97 +2.77 4.55 7.17 18.40 +5.27 7.00 18.98 19.05 +9.04 10.00 7.00 11.81 +8.78 8.91 7.60 11.37 +3.43 7.31 16.15 19.01 +7.39 8.02 16.37 18.79 +2.61 2.61 6.36 9.36 +7.65 9.23 7.16 14.36 +1.00 8.47 7.13 13.04 +9.64 10.00 9.12 15.69 +6.03 8.69 1.81 2.03 +8.78 9.87 15.66 18.75 +9.13 10.00 12.18 19.89 +6.43 9.67 12.84 12.91 +7.77 9.10 15.29 19.25 +1.19 9.13 6.12 14.57 +7.30 9.21 9.16 15.01 +1.60 7.40 3.67 12.07 +3.54 6.73 15.71 18.35 +4.45 4.88 19.11 20.00 +3.13 6.10 16.21 17.69 +5.28 7.44 13.93 16.82 +7.32 8.13 13.06 15.49 +5.14 8.16 4.42 6.10 +7.63 9.01 13.59 14.43 +8.72 9.34 2.36 13.26 +0.87 5.65 6.13 19.49 +2.09 4.81 3.28 6.47 +3.89 6.85 14.81 16.59 +8.33 8.56 8.73 17.73 +7.91 8.28 8.53 10.67 +7.15 9.16 7.77 19.69 +10.00 10.00 8.53 19.64 +8.11 9.64 12.26 18.92 +3.77 6.52 14.23 18.92 +7.48 9.38 19.89 20.00 +8.13 8.54 8.43 16.32 +7.19 7.42 5.72 6.27 +0.29 2.72 8.66 16.81 +1.04 9.24 12.36 19.18 +9.24 10.00 3.50 5.02 +8.63 9.89 4.83 11.87 +1.80 6.98 5.24 5.58 +9.39 10.00 17.94 19.21 +3.64 7.88 0.52 19.85 +2.20 3.44 8.76 11.87 +0.98 6.88 15.62 18.64 +3.55 9.03 10.31 14.24 +5.65 9.21 8.01 12.78 +2.71 5.71 6.05 10.11 +9.54 10.00 3.08 4.38 +7.53 9.13 13.27 14.43 +1.37 4.86 6.89 15.54 +3.12 9.21 13.81 15.81 +4.39 7.45 11.75 16.49 +2.99 6.11 18.15 19.01 +8.08 9.87 3.01 12.66 +2.45 3.12 19.33 20.00 +3.33 9.11 6.59 12.31 +5.82 8.09 5.92 18.99 +8.85 9.30 5.77 10.83 +9.55 10.00 15.29 19.50 +7.76 9.27 6.71 19.35 +5.58 8.15 13.14 19.93 +2.85 4.97 5.59 8.33 +5.94 7.40 19.33 20.00 +5.96 7.42 17.96 19.12 +2.46 2.84 19.51 20.00 +2.68 7.95 1.99 19.03 +7.63 8.99 15.41 16.44 +0.37 0.82 7.50 14.41 +8.68 9.26 14.89 16.30 +5.15 6.71 10.97 18.96 +4.91 7.29 5.06 7.21 +4.70 9.07 4.98 18.98 +6.85 8.50 7.93 16.78 +4.57 6.14 9.44 16.55 +6.54 7.29 2.59 11.72 +9.86 10.00 6.76 16.73 +6.44 8.12 7.41 11.54 +6.11 6.12 11.75 18.41 +9.02 10.00 14.16 16.88 +1.87 4.04 16.95 19.41 +8.66 9.08 6.65 16.38 +3.58 4.29 10.56 11.34 +5.83 6.12 18.98 19.27 +4.86 6.61 9.55 19.74 +9.42 10.00 16.12 16.53 +5.87 7.71 18.56 19.49 +9.99 10.00 18.61 18.70 +9.16 10.00 0.29 15.66 +4.16 8.60 8.07 17.30 +0.05 5.36 15.07 18.51 +7.20 7.52 12.77 15.39 +2.65 6.10 5.39 15.25 +6.70 7.89 18.41 19.38 +7.63 9.52 9.39 19.34 +8.00 8.58 9.74 10.34 +3.00 5.93 1.17 4.14 +8.12 8.15 14.54 17.53 +0.04 1.68 7.72 10.78 +0.38 3.60 0.09 4.18 +7.28 9.95 4.02 4.16 +6.96 7.85 8.94 13.80 +6.84 9.68 11.10 13.83 +2.54 3.49 12.55 14.30 +2.55 4.09 6.33 15.66 +3.27 4.12 16.70 18.52 +4.25 7.51 14.09 19.78 +1.17 4.55 2.12 3.81 +2.37 4.41 2.86 10.20 +7.80 9.82 0.46 15.26 +6.32 7.28 11.31 18.74 +2.38 3.90 16.10 19.14 +7.50 8.80 18.37 18.79 +9.58 10.00 7.29 19.09 +3.92 7.71 2.86 14.21 +3.72 8.21 13.20 16.42 +4.45 8.33 17.26 18.18 +4.45 4.45 17.26 17.26 diff --git a/solutions/beecrowd/2295/out.txt b/solutions/beecrowd/2295/out.txt new file mode 100644 index 00000000..fa4bec15 --- /dev/null +++ b/solutions/beecrowd/2295/out.txt @@ -0,0 +1,301 @@ +A +G +G +A +G +G +G +G +A +G +G +A +A +A +G +G +A +A +G +A +G +G +G +A +A +G +A +G +G +A +A +A +A +G +G +G +G +G +G +G +A +A +G +G +A +A +G +G +A +G +G +G +A +G +A +A +G +G +G +G +G +A +G +G +G +A +A +A +A +A +A +G +A +G +G +A +G +G +G +G +G +G +G +G +G +G +A +G +G +G +G +A +G +G +A +G +G +G +G +G +G +A +A +A +G +A +A +G +G +G +A +G +G +A +G +A +G +A +A +G +A +G +A +G +G +A +G +G +G +A +A +A +A +G +A +A +A +G +A +A +G +G +A +A +G +G +G +A +A +G +G +G +G +A +G +G +A +A +A +G +G +G +G +G +A +A +G +A +G +A +A +G +A +A +G +G +G +A +A +A +G +G +A +G +G +A +G +G +G +A +G +A +G +G +A +G +A +G +A +A +A +A +A +G +A +A +G +A +A +A +G +G +G +G +G +A +A +G +G +A +A +G +G +A +G +G +A +A +A +A +A +G +A +A +A +A +A +G +A +A +G +G +G +G +G +A +A +A +A +G +A +A +G +G +A +G +G +G +G +G +G +G +G +A +G +A +A +G +A +A +G +G +G +A +G +G +A +G +A +G +G +A +G +A +G +A +A +G +A +A +A +G +G +G +A +A +G +G +A +A +G diff --git a/solutions/beecrowd/2295/problem.md b/solutions/beecrowd/2295/problem.md new file mode 100644 index 00000000..9a3df668 --- /dev/null +++ b/solutions/beecrowd/2295/problem.md @@ -0,0 +1,40 @@ +https://judge.beecrowd.com/en/problems/view/2295 + +# Frota de Táxi + +A Companhia de Táxi Tabajara (CTT) é uma das maiores empresas de transporte do +país. Possui uma vasta frota de carros e opera em todas as grandes cidades. +Recentemente a CTT modernizou a sua frota, adquirindo um lote de 500 carros +bi-combustíveis (carros que podem utilizar como combustível tanto álcool quanto +gasolina). Além do maior conforto para os passageiros e o menor gasto com +manutenção, com os novos carros é possível uma redução adicional de custo: como +o preço da gasolina está sujeito a variações muito bruscas e pode ser vantagem, +em certos momentos, utilizar álcool como combustível. Entretanto, os carros +possuem um melhor desempenho utilizando gasolina, ou seja, em geral, um carro +percorre mais quilômetros por litro de gasolina do que por litro de álcool. + +Você deve escrever um programa que, dados o preço do litro de álcool, o preço do +litro de gasolina e os quilômetros por litro que um carro bi-combustível realiza +com cada um desses combustíveis, determine se é mais econômico abastecer os +carros da CTT com álcool ou com gasolina. No caso de não haver diferença de +custo entre abastecer com álcool ou gasolina a CTT prefere utilizar gasolina. + +## Entrada + +A entrada é composta por uma linha contendo quatro números reais com precisão de +duas casas decimais $A$ e $G (0.01 \leq A, G \leq 10.00)$ $R_a$ e $R_g (0.01 +\leq R_a , R_g \leq 20.00)$ representando respectivamente o preço por litro do +álcool, o preço por litro da gasolina, o rendimento (km/l) do carro utilizando +álcool e o rendimento (km/l) do carro utilizando gasolina. + +A entrada deve ser lida do dispositivo de entrada padrão (normalmente o +teclado). + +## Saída + +A saída deve ser composta por uma única linha contendo o caractere ‘A’ se é mais +econômico abastecer a frota com álcool ou o caractere ‘G’ se é mais econômico ou +indiferente abastecer a frota com gasolina. + +A saída deve ser escrita no dispositivo de saída padrão (normalmente a tela). + diff --git a/solutions/beecrowd/2295/tags.txt b/solutions/beecrowd/2295/tags.txt new file mode 100644 index 00000000..e07a45e3 --- /dev/null +++ b/solutions/beecrowd/2295/tags.txt @@ -0,0 +1 @@ +ad-hoc