-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.py
More file actions
57 lines (51 loc) · 1.28 KB
/
lib.py
File metadata and controls
57 lines (51 loc) · 1.28 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
f = open("f_libraries_of_the_world.txt", "r")
books,library,days=f.readline().split()
books=int(books)
library=int(library)
days=int(days)
scores=list(map(int,f.readline().split()))
lib_att=list()
arr_book=list()
for i in range(library):
temp=list(map(int,f.readline().split()))
temp.append(i)
#lib_att.append(temp)
temp1=list(map(int,f.readline().split()))
sum=0
for l in range(len(temp1)):
#print(temp1[l])
sum=sum+scores[temp1[l]]
#sum=sum+(arr_book[(temp1[l])])
demo=sum//temp[1]
temp1.append(demo)
for z in temp1:
temp.append(z)
lib_att.append(temp)
#print(*lib_att)
tt=open("f.txt", "w")
lib_att.sort(key = lambda x: x[-1],reverse=True)
count=0
sum_days=0
for j in range(library):
if(sum_days+lib_att[i][1]<=days):
count=count+1
print(count,file=tt)
for k in range(count):
print(lib_att[k][3],end=" ",file=tt)
print(len(lib_att[k])-4,file=tt)
print(*lib_att[k][4:],file=tt)
#arr_book.append(temp1)
"""
sum_days=0
lib_index=list()
for i in reversed(range(library)):
if (sum_days+lib_att[i][1]<=days):
lib_index.append(i)
sum_days=sum_days+lib_att[i][1]
tt=open("f.txt", "w")
print(len(lib_index),file=tt)
for j in lib_index:
print(j,end=" ",file=tt)
print(len(arr_book[j]),file=tt)
print(*arr_book[j],file=tt)
"""