|
|
back to boardPython 3 Wrong Answer Posted by Dmitry 4 Oct 2015 12:05 import sys def wall_scaner(amount, wall): count = 0 high = 0 mid_number = '' while count < int(amount) - 2: summ = 0 unit = wall[count:count + 3] for i in unit: summ += int(i) if summ > high: high = summ mid_number = count + 2 count += 1 return high, mid_number data1 = sys.stdin.readline() data2 = sys.stdin.readline() amount = ''.join(data1.split()) wall = ''.join(data2.split()) answer = wall_scaner(amount, wall) print(answer[0], answer[1]) plz tell me what's wrong this code always return right format and answer for me Re: Python 3 Wrong Answer Posted by Vigi 8 Oct 2015 15:59 ты считаешь тройки одинаковых рядом цифр, а по заданию это не нужно. Нужно найти суммарный максимум из рядом стоящих не обязательно это будут 777 может и 845 n = int(input()) sp = list(map(int, (input().split()))) ind = 0 MAX = sum(sp[:2]) for i in range(n - 2): if sum(sp[i:i+3]) > MAX: MAX = sum(sp[i:i+3]) ind = sp.index(sp[i]) + 2 print(MAX, ind) Edited by author 08.10.2015 18:07 |
|
|