結果

問題 No.1890 Many Sequences Sum Queries
ユーザー かもめのうでかもめのうで
提出日時 2023-09-26 12:39:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 333 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 90,432 KB
最終ジャッジ日時 2023-09-26 12:39:36
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 320 ms
89,392 KB
testcase_01 AC 333 ms
90,432 KB
testcase_02 AC 71 ms
71,388 KB
testcase_03 AC 71 ms
71,472 KB
testcase_04 AC 75 ms
75,900 KB
testcase_05 AC 78 ms
71,592 KB
testcase_06 AC 81 ms
81,208 KB
testcase_07 AC 184 ms
89,500 KB
testcase_08 AC 119 ms
89,664 KB
testcase_09 AC 125 ms
89,744 KB
testcase_10 AC 328 ms
90,288 KB
testcase_11 AC 211 ms
90,124 KB
testcase_12 AC 256 ms
89,448 KB
testcase_13 AC 264 ms
89,516 KB
testcase_14 AC 183 ms
89,360 KB
testcase_15 AC 70 ms
71,544 KB
testcase_16 AC 71 ms
71,492 KB
testcase_17 AC 72 ms
71,552 KB
testcase_18 AC 72 ms
71,552 KB
testcase_19 AC 72 ms
71,556 KB
testcase_20 AC 73 ms
71,512 KB
testcase_21 AC 73 ms
71,488 KB
testcase_22 AC 71 ms
71,592 KB
testcase_23 AC 71 ms
71,384 KB
testcase_24 AC 72 ms
71,368 KB
testcase_25 AC 71 ms
71,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
    for j in range(1, i+1):
        b.append(j)
# print(b)
rui = list(accumulate(b, initial=0))
# print(rui)

for i in range(q):
    x = int(input())
    ng = -1
    ok = len(rui)
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if rui[mid] >= x:
            ok = mid
        else:
            ng = mid
    if ok == len(rui):
        print(-1)
    else:
        print(ok)
0