forked from beatsey/minorProjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmincontainers.py
More file actions
42 lines (32 loc) · 1.01 KB
/
Copy pathmincontainers.py
File metadata and controls
42 lines (32 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
41
42
# Номер 3
def func():
volume, M = [int(X) for X in input().split(' ')]
sortedVolumes=[]
for i in range(1,M+1):
V = float(input())
if(volume-V>=0):
sortedVolumes.append((V,i))
volume-=V
else:
sortedVolumes.sort(key=lambda x:x[0])
if sortedVolumes[0][0]<V:
volume=volume+sortedVolumes[0][0]-V
sortedVolumes[0]=(V,i)
if len(sortedVolumes)==0:
print('NO')
return
# Удаляем лишние кастрюли
sortedVolumes.sort(key=lambda x:x[0])
for i in range(len(sortedVolumes)):
volume += sortedVolumes[i][0]
if(volume>0):
index=i
break
# Выводим индексы всех предметов начиная с index
sortedVolumes=sortedVolumes[index::]
sortedVolumes.sort(key=lambda x:x[1])
out=''
for i in range(len(sortedVolumes)):
out+='{}\n'.format(sortedVolumes[i][1])
print(out)
func()