/
ne-ilyxa
/
AP1_Py_T01
Обзор
Документация
Войти
/
ne-ilyxa
/
AP1_Py_T01
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/exercise10.py
51 строка
1 KB
git1worker
Finished
16 авг 2025, 14:22
16 авг 2025, 14:22
e5a8f98
Код
Авторство
О чём код?
def checkNum(num): for i in range(len(num)): if num[i] < '0' or num[i] > '9': return False return True raw = input().split() if not (checkNum(raw[0]) and int(raw[0]) > 0 and checkNum(raw[1]) and int(raw[1]) > 0 and len(raw) == 2): print("Natural numbers are expected") exit() quantity_av_devs = int(raw[0]) req_time_work = int(raw[1]) devices = [] for r in range(quantity_av_devs): raw = input().split() if len(raw) != 3: print("Incorrect input") exit() devices.append([]) for i in raw: if not (checkNum(i) and int(i) > 0): print("Natural numbers are expected") exit() devices[r].append(int(i)) # print(quantity_av_devs, req_time_work) # print(devices) # Найти время сначала, уже у совпавших проверять год, после стоимость potential_pair_devices = [] for i in range(len(devices)): if devices[i][2] >= req_time_work: continue for j in range(i + 1, len(devices)): if devices[i][2] + devices[j][2] == req_time_work and devices[i][0] == devices[j][0]: potential_pair_devices.append([devices[i], devices[j]]) best_option = potential_pair_devices[0] for i in potential_pair_devices: if i[0][1] + i[1][1] < best_option[0][1] + best_option[1][1]: best_option = i print(best_option[0][1] + best_option[1][1])