質問するログイン新規登録

回答編集履歴

3

修正

2020/08/23 05:36

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -16,7 +16,7 @@
16
16
  ## 修正点
17
17
 
18
18
  累積和の計算に [itertools.accumulate](https://docs.python.org/ja/3/library/itertools.html#itertools.accumulate) を使うことで4倍程度高速化できました。
19
- Python の標準ライブラリの関数は C で実装されている場合があり、その場合は Python のコードを書くより高速の場合があるため、標準ライブラリの関数でできる処理は自前で書くより関数を使ましょう。
19
+ Python の標準ライブラリの関数は C で実装されている場合があり、その場合は Python のコードを書くより高速となるため、標準ライブラリの関数でできる処理は積極的に使うようにしましょう。
20
20
 
21
21
  ```python
22
22
  lst = list(range(100000))

2

修正

2020/08/23 05:36

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -16,6 +16,7 @@
16
16
  ## 修正点
17
17
 
18
18
  累積和の計算に [itertools.accumulate](https://docs.python.org/ja/3/library/itertools.html#itertools.accumulate) を使うことで4倍程度高速化できました。
19
+ Python の標準ライブラリの関数は C で実装されている場合があり、その場合は Python のコードを書くより高速の場合があるため、標準ライブラリの関数でできる処理は自前で書くより関数を使いましょう。
19
20
 
20
21
  ```python
21
22
  lst = list(range(100000))

1

修正

2020/08/23 05:35

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -4,7 +4,7 @@
4
4
  from itertools import accumulate
5
5
 
6
6
  N = int(input())
7
- lst = tuple(map(int, input().strip().split(" ")))
7
+ lst = tuple(map(int, input().strip().split(" "))) # N = 10000 の入力の末尾になぜか空白が入ってるので strip() で除いた
8
8
  M = int(input())
9
9
 
10
10
  S = [0] + list(accumulate(lst))