Kaynağa Gözat

Qual-b: final solution

Gildas Chabot 8 yıl önce
ebeveyn
işleme
315ec8e562

+ 29 - 0
2017.0-QualificationRound/b.LazyLoading.py

@@ -0,0 +1,29 @@
1
+import numpy as np
2
+
3
+def solve(N, W):
4
+    W=sorted(W)
5
+    res=0
6
+    #print("Start:", W)
7
+    while len(W) > 0:
8
+        last=W[-1]
9
+        del W[-1]
10
+        #print("Removed last:", W)
11
+        div=int(np.ceil(50/last))
12
+        #print("50/{0}={1}".format(last,div))
13
+        if len(W) < div-1:
14
+            return res
15
+        del W[:div-1]
16
+        #print("Removed", div-1, "first")
17
+        res+=1
18
+    return res
19
+
20
+if __name__ == "__main__":
21
+    import fileinput
22
+    f = fileinput.input()
23
+
24
+    T = int(f.readline())
25
+    for case in range(1, T+1):
26
+        N = int(f.readline())
27
+        W = [int(f.readline()) for x in range(N)]
28
+        solution = solve(N, W)
29
+        print("Case #{0}: {1}".format(case, solution))

+ 40 - 0
2017.0-QualificationRound/b.in

@@ -0,0 +1,40 @@
1
+5
2
+4
3
+30
4
+30
5
+1
6
+1
7
+3
8
+20
9
+20
10
+20
11
+11
12
+1
13
+2
14
+3
15
+4
16
+5
17
+6
18
+7
19
+8
20
+9
21
+10
22
+11
23
+6
24
+9
25
+19
26
+29
27
+39
28
+49
29
+59
30
+10
31
+32
32
+56
33
+76
34
+8
35
+44
36
+60
37
+47
38
+85
39
+71
40
+91