結果

問題 No.1890 Many Sequences Sum Queries
ユーザー rlangevinrlangevin
提出日時 2023-01-11 20:34:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 83,916 KB
最終ジャッジ日時 2023-08-24 01:50:52
合計ジャッジ時間 5,613 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 319 ms
80,000 KB
testcase_01 AC 342 ms
83,892 KB
testcase_02 AC 71 ms
71,112 KB
testcase_03 AC 70 ms
71,428 KB
testcase_04 AC 74 ms
75,772 KB
testcase_05 AC 71 ms
71,232 KB
testcase_06 AC 73 ms
76,964 KB
testcase_07 AC 194 ms
82,620 KB
testcase_08 AC 138 ms
83,264 KB
testcase_09 AC 142 ms
83,916 KB
testcase_10 AC 326 ms
82,440 KB
testcase_11 AC 221 ms
82,888 KB
testcase_12 AC 257 ms
83,116 KB
testcase_13 AC 274 ms
82,236 KB
testcase_14 AC 198 ms
83,036 KB
testcase_15 AC 72 ms
71,232 KB
testcase_16 AC 69 ms
70,988 KB
testcase_17 AC 71 ms
71,200 KB
testcase_18 AC 69 ms
71,384 KB
testcase_19 AC 69 ms
71,080 KB
testcase_20 AC 70 ms
71,180 KB
testcase_21 AC 70 ms
71,408 KB
testcase_22 AC 70 ms
71,000 KB
testcase_23 AC 71 ms
71,236 KB
testcase_24 AC 71 ms
71,408 KB
testcase_25 AC 70 ms
71,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

N, Q = map(int, input().split())
A = list(map(int, input().split()))
L = []
for a in A:
    L.extend(list(range(1, a + 1)))
M = len(L)
Ac = [0] * (M + 1)
for i in range(M):
    Ac[i + 1] = Ac[i] + L[i]

for i in range(Q):
    s = int(input())
    ind = bisect_left(Ac, s)
    if ind == M + 1:
        print(-1)
    else:
        print(ind)
0