Submission #716150

#TimeUsernameProblemLanguageResultExecution timeMemory
716150vjudge1Growing Vegetables is Fun 4 (JOI21_ho_t1)Cpython 3
0 / 100
1076 ms3308 KiB
n = int(input()) ai = input() # n = 8 # ai = "12 2 34 85 4 91 29 85" ml = [] def generate_ml(): final = [] for i in ai.split(" "): final.append(int(i)) return final ml = generate_ml() def focus(ai_list, focus): total = 0 b = [focus, focus] # b = broaden(b[0], b[1], ml) # initial broaden-ification while (b[0] > 0) and (ai_list[b[0]-1] < ai_list[b[0]]): b[0] -= 1 while (b[1] < n-1) and (ai_list[b[1]] > ai_list[b[1]+1]): b[1] += 1 while (b != [0, n-1]): if (b[0] == 0): left_side = 10**14 else: left_side = ai_list[b[0]-1] - ai_list[b[0]] if (b[1] == n-1): right_side = 10**14 else: right_side = ai_list[b[1]+1] - ai_list[b[1]] amount = min(left_side, right_side) + 1 total += amount ai_list[b[0]] += amount ai_list[b[1]] += amount # b = broaden(b[0], b[1], ai_list) while (b[0] > 0) and (ai_list[b[0]-1] < ai_list[b[0]]): b[0] -= 1 while (b[1] < n-1) and (ai_list[b[1]] > ai_list[b[1]+1]): b[1] += 1 return total def main(): main_list = generate_ml() min = focus(main_list, 0) for i in range(1, n): main_list = generate_ml() count = focus(main_list, i) if count<min: min = count print(min) main()
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...