diff --git a/1. Iniciante/3170.py b/1. Iniciante/3170.py new file mode 100644 index 0000000..94271ea --- /dev/null +++ b/1. Iniciante/3170.py @@ -0,0 +1,10 @@ +from sys import stdin, stdout + +b = int(stdin.readline().strip()) +g = int(stdin.readline().strip()) + +quantidade_necessaria = g//2 +if b>=quantidade_necessaria: + stdout.write("Amelia tem todas bolinhas!\n") +else: + stdout.write(f"Faltam {quantidade_necessaria-b} bolinha(s)\n") diff --git a/2. AD-HOC/1397.py b/2. AD-HOC/1397.py new file mode 100644 index 0000000..256398e --- /dev/null +++ b/2. AD-HOC/1397.py @@ -0,0 +1,17 @@ +import sys + +while (n := int(sys.stdin.readline().strip())) != 0: + ca = 0 + cb = 0 + + for i in range(n): + l = sys.stdin.readline().strip() + + a, b = [int(x) for x in l.split()] + + if a>b: + ca+=1 + elif b>a: + cb+=1 + + sys.stdout.write(f"{ca} {cb}\n") \ No newline at end of file diff --git a/2. AD-HOC/2448.py b/2. AD-HOC/2448.py new file mode 100644 index 0000000..a8f7c7d --- /dev/null +++ b/2. AD-HOC/2448.py @@ -0,0 +1,25 @@ +from sys import stdin, stdout + +linha = stdin.readline().strip() +n, m = linha.split() + +linha2 = stdin.readline().strip() +casas = [int(x) for x in linha2.split()] + +linha3 = stdin.readline().strip() +encomendas = [int(x) for x in linha3.split()] + +indices : dict[int, int] = {} +idx = 0 +soma = 0 + + +for i, casa in enumerate(casas): + indices[casa] = int(i) + +for encomenda in encomendas: + casa = indices[encomenda] + soma+=abs(indices[encomenda] - idx) + idx = casa + +stdout.write(str(soma) + '\n') diff --git a/4. Estruturas e Bibliotecas/1449.py b/4. Estruturas e Bibliotecas/1449.py new file mode 100644 index 0000000..852231e --- /dev/null +++ b/4. Estruturas e Bibliotecas/1449.py @@ -0,0 +1,26 @@ +from sys import stdin, stdout + +for t in range(int(stdin.readline().strip())): + m,n = stdin.readline().strip().split() + + jap = [] + trad = [] + + for x in range(int(m)): + jap.append(stdin.readline().strip()) + trad.append(stdin.readline().strip()) + + musica = [] + + for x in range(int(n)): + linha = str(stdin.readline().strip()) + lista_palavras = linha.split() + for idx, palavra in enumerate(lista_palavras): + for org, pt in zip(jap, trad): + if palavra == org: + lista_palavras[idx] = pt + musica.append(" ".join(lista_palavras)) + + for linha in musica: + stdout.write(linha+'\n') + stdout.write("\n") \ No newline at end of file