-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcook_off2.py
More file actions
40 lines (39 loc) · 1.01 KB
/
cook_off2.py
File metadata and controls
40 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import bisect
# for _ in range(int(input())):
n = int(input())
li = list(map(int, input().split()))
arr = [1] * n
# print(arr)
# a, b = list(map(int, input().split()))
operations = 0
ans = []
done = [False]*n
for i in range(n):
# done = False
if li[i] == arr[i]:
done[i] = True
continue
while li[i] > arr[i]:
ans.append([1, i+1])
operations+=1
arr[i] *= 2
if li[i] < arr[i]:
for j in range(i+2):
if i!=j and arr[i] - li[i] == arr[j]:
ans.append([2, i+1, j+1])
operations+=1
arr[i] -= arr[j]
done[i] = True
break
if done[j] == False and arr[j] - li[j] == arr[i]:
ans.append([2, j+1, i+1])
operations+=1
arr[j] -= arr[i]
done[j] = True
break
# if done[i] != True:
# done[i] = False
sorted_arr = sorted(arr)
for i in range(n):
if done[i] == True:
continue