Задача H, не проходит третий тест
summ = 0
max_summ = 0
w = ""
for i in range(n):
m = input()
c = int(input())
while c != 0:
summ += c % 10
c //= 10
if max_summ < summ:
max_summ = summ
w = m
elif max_summ == summ:
max_summ = summ
w = m
print(w)
утро
задача P "Анонс новости 2.0" - спотыкается на 22-м тесте - видимо я неправильно понимаю условие задачи
мне бы намек, куда копать
length = int(input())
result_list = []
for _ in range(int(input())):
result_list.append(input())
for text in result_list:
text_len = len(text)
difference = length - text_len
if difference >= 3:
length -= text_len
else:
text = text[:(difference - 3)] + '...'
length = 0
print(text)
if length == 0:
break
times = [int(input()) for _ in range(2)]
names = [str(input()) for __ in range(times[0] + times[1])]
names_without_repeat = set(names)
for i in names:
if names.count(i) > 1:
try:
names_without_repeat.remove(i)
except KeyError:
continue
if names_without_repeat == set():
print('Таких нет')
else:
print(len(names_without_repeat))
Всем привет!
Застряла на задаче «Властелин Чисел: Две Башни»
Выдавет «Неправильный ответ» на 3-м тесте. В IDE у меня все нормально работает, какие числа только не пробовала. Подскажите, плиз, что не так.
Код:
number = int(input())
digit_1 = int(number / 100) % 10
digit_2 = int(number / 10) % 10
digit_3 = number % 10
case_1 = int(str(digit_1) + str(digit_2))
case_2 = int(str(digit_1) + str(digit_3))
case_3 = int(str(digit_2) + str(digit_3))
case_4 = int(str(digit_2) + str(digit_1))
case_5 = int(str(digit_3) + str(digit_1))
case_6 = int(str(digit_3) + str(digit_2))
max = max(case_1, case_2, case_3, case_4, case_5, case_6)
if 10 <= case_1 < case_2 and case_3 and case_4 and case_5 and case_6:
print(case_1, max)
elif 10 <= case_2 < case_1 and case_3 and case_4 and case_5 and case_6:
print(case_2, max)
elif 10 <= case_3 < case_1 and case_2 and case_4 and case_5 and case_6:
print(case_3, max)
elif 10 <= case_4 < case_1 and case_2 and case_3 and case_5 and case_6:
print(case_4, max)
elif 10 <= case_5 < case_1 and case_2 and case_3 and case_4 and case_6:
print(case_5, max)
elif 10 <= case_6 < case_1 and case_2 and case_3 and case_4 and case_5:
print(case_6, max)
Вроде я в список ошибочные ответы добавлял, но возможно, что правильные. Я уже не возле компьютера, не помню == или != использовал.
А вообще, странно, что код хоть один тест прошел. У меня на строчке max = max(…) сразу упал.