結果

問題 No.1890 Many Sequences Sum Queries
ユーザー kept1994kept1994
提出日時 2022-05-03 02:45:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 89,892 KB
最終ジャッジ日時 2023-09-15 00:40:17
合計ジャッジ時間 5,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 338 ms
89,484 KB
testcase_01 AC 358 ms
89,452 KB
testcase_02 AC 76 ms
71,312 KB
testcase_03 AC 75 ms
71,404 KB
testcase_04 AC 81 ms
75,524 KB
testcase_05 AC 74 ms
71,440 KB
testcase_06 AC 81 ms
80,424 KB
testcase_07 AC 210 ms
89,352 KB
testcase_08 AC 143 ms
89,456 KB
testcase_09 AC 151 ms
89,496 KB
testcase_10 AC 340 ms
89,684 KB
testcase_11 AC 230 ms
89,892 KB
testcase_12 AC 275 ms
89,500 KB
testcase_13 AC 286 ms
89,424 KB
testcase_14 AC 208 ms
89,248 KB
testcase_15 AC 73 ms
71,348 KB
testcase_16 AC 73 ms
71,328 KB
testcase_17 AC 72 ms
71,472 KB
testcase_18 AC 74 ms
71,280 KB
testcase_19 AC 73 ms
71,412 KB
testcase_20 AC 72 ms
71,344 KB
testcase_21 AC 75 ms
71,580 KB
testcase_22 AC 72 ms
71,516 KB
testcase_23 AC 72 ms
71,176 KB
testcase_24 AC 72 ms
71,552 KB
testcase_25 AC 72 ms
71,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
from bisect import bisect_left
from itertools import accumulate
import sys

MOD = 998244353

def main():
    N, Q = map(int, input().split())
    A = list(map(int, input().split()))
    B = []
    for aa in A:
        for i in range(1, aa + 1):
            B.append(i)
    SB = list(accumulate(B))
    m = len(SB)
    # print(SB)
    for _ in range(Q):
        S = int(input())
        if S == SB[-1]:
            print(m)
            continue
        ans = bisect_left(SB, S)
        print(ans + 1 if ans < m else -1)
    return

if __name__ == '__main__':
    main()

0