timelimit exceeded とエラーが出ました。
a_str =[7,4,5] num_array =[[1, 3, 1], [3, 2, 2], [2, 3, 5], [3, 4, 4], [1, 6, 6]] select_one =[] def check_last_one(num_array): for i in range(a_str[2]): if num_array[i][0] == 1: select_one.append(num_array[i]) check_last_one(num_array) start_array =[] def max_of_middle(a): return a[1] start_array =max(select_one, key = max_of_middle) print(start_array) def get_next_point(array): if array[0] == 4: return array[0] -1 elif array[0] == 1: return array[0] +1 else: return array[0] +1 select_array =[] def get_next_array(array): next_point = get_next_point(start_array) for i in range(len(num_array)): if num_array[i][1] == next_point: select_array.append(num_array[i]) next_point = get_next_point(num_array[i]) else: select_array.append([0,0,0]) get_next_array(start_array) print(select_array) next_array =[] def big_or_small(select_array): next_array =max(select_array, key =max_of_middle) return next_array x1 =big_or_small(select_array) print(x1) left = a_str[0] left =x1[1] while select_array !=[0,0,0]: get_next_array(start_array) x1 =big_or_small(select_array) left =x1[1] print(x1[0])
と書いたコードを実行するとそのエラーが出ました。
「timelimit exceeded」が発生する環境を追記ください(オンライン実行環境?)
はい、オンライン実行環境です
回答2件
あなたの回答
tips
プレビュー