回答編集履歴

4

修正

2017/11/16 13:14

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -24,8 +24,6 @@
24
24
 
25
25
  human_total += 1
26
26
 
27
- print(score_total, human_total)
28
-
29
27
  if human_total >= num_of_human:
30
28
 
31
29
  break

3

修正・追記

2017/11/16 13:14

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -1,13 +1,41 @@
1
- すみません、ちょっと問題設定を勘違していました。
1
+ すみません、修正しました。慌てて作ったのでちょっと良くなコードですね...
2
2
 
3
- 下記の回答はスルーしてください。
3
+ ```Python
4
+
5
+ score = [500, 400, 300, 200, 100, 50, 0]
6
+
7
+ amount = [3, 8, 3, 5, 10, 3, 1]
4
8
 
5
9
 
6
10
 
7
- スライスを使えばよいです。
11
+ num_of_human = 10
8
12
 
9
- ```Python
10
13
 
14
+
15
+ score_total = 0
16
+
17
+ human_total = 0
18
+
19
+ for s, a in zip(score, amount):
20
+
21
+ for h in range(a):
22
+
23
+ score_total += s
24
+
25
+ human_total += 1
26
+
27
+ print(score_total, human_total)
28
+
29
+ if human_total >= num_of_human:
30
+
31
+ break
32
+
33
+ if human_total >= num_of_human:
34
+
35
+ break
36
+
37
+
38
+
11
- wt_avg = sum([s*a for s,a in zip(score[:n],amount[:n])]) / sum(amount[:n])
39
+ wt_avg = score_total / num_of_human
12
40
 
13
41
  ```

2

修正

2017/11/16 13:13

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -1,3 +1,9 @@
1
+ すみません、ちょっと問題設定を勘違いしていました。
2
+
3
+ 下記の回答はスルーしてください。
4
+
5
+
6
+
1
7
  スライスを使えばよいです。
2
8
 
3
9
  ```Python

1

修正

2017/11/16 12:54

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  ```Python
4
4
 
5
- wt_avg = sum([s*a for s,a in zip(score[:n],amount[:n])]) / n
5
+ wt_avg = sum([s*a for s,a in zip(score[:n],amount[:n])]) / sum(amount[:n])
6
6
 
7
7
  ```