結果

問題 No.1890 Many Sequences Sum Queries
ユーザー lam6er
提出日時 2025-03-20 21:11:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 82,544 KB
実行使用メモリ 104,836 KB
最終ジャッジ日時 2025-03-20 21:11:10
合計ジャッジ時間 3,472 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

import bisect
import itertools
def main():
import sys
input = sys.stdin.read
data = input().split()
index = 0
N = int(data[index])
index += 1
Q = int(data[index])
index += 1
A = list(map(int, data[index:index+N]))
index += N
cum_sum = []
current_sum = 0
for a in A:
add = itertools.accumulate(range(1, a + 1))
new_sums = [current_sum + x for x in add]
cum_sum.extend(new_sums)
current_sum = new_sums[-1] if new_sums else current_sum
total = current_sum
S = list(map(int, data[index:index+Q]))
index += Q
for s in S:
if s > total:
print(-1)
else:
pos = bisect.bisect_left(cum_sum, s)
print(pos + 1)
if __name__ == "__main__":
main()
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0