結果

問題 No.1093 区間の和 / Sum of Range
ユーザー ああいいああいい
提出日時 2021-12-25 10:27:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 971 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 21,748 KB
最終ジャッジ日時 2023-10-21 11:03:16
合計ジャッジ時間 18,645 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,220 KB
testcase_01 AC 424 ms
14,884 KB
testcase_02 AC 197 ms
11,524 KB
testcase_03 AC 112 ms
19,740 KB
testcase_04 AC 87 ms
21,240 KB
testcase_05 AC 624 ms
14,384 KB
testcase_06 AC 135 ms
13,868 KB
testcase_07 AC 332 ms
15,012 KB
testcase_08 AC 271 ms
21,268 KB
testcase_09 AC 503 ms
12,708 KB
testcase_10 AC 304 ms
18,244 KB
testcase_11 AC 715 ms
14,936 KB
testcase_12 AC 461 ms
17,440 KB
testcase_13 AC 32 ms
10,580 KB
testcase_14 AC 863 ms
13,864 KB
testcase_15 AC 192 ms
15,036 KB
testcase_16 AC 971 ms
17,412 KB
testcase_17 AC 739 ms
12,464 KB
testcase_18 AC 530 ms
13,884 KB
testcase_19 AC 65 ms
11,908 KB
testcase_20 AC 421 ms
11,608 KB
testcase_21 AC 914 ms
14,244 KB
testcase_22 AC 931 ms
17,820 KB
testcase_23 AC 619 ms
12,064 KB
testcase_24 AC 126 ms
20,984 KB
testcase_25 AC 661 ms
15,084 KB
testcase_26 AC 572 ms
17,660 KB
testcase_27 AC 466 ms
14,020 KB
testcase_28 AC 544 ms
18,192 KB
testcase_29 AC 849 ms
21,748 KB
testcase_30 AC 140 ms
12,268 KB
testcase_31 AC 183 ms
14,248 KB
testcase_32 AC 271 ms
15,368 KB
testcase_33 AC 890 ms
17,872 KB
testcase_34 AC 72 ms
11,084 KB
testcase_35 AC 523 ms
11,536 KB
testcase_36 AC 750 ms
20,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
a = list(map(int,input().split()))

S = []

ans = 0
for i in range(K):
    ans += a[i]
S.append(ans)
j = 1
while j + K -1 < N:
    ans = S[-1] + a[j+K-1] - a[j-1]
    S.append(ans)
    j += 1
S.sort()
Q = int(input())
for _ in range(Q):
    x = int(input())
    if S[-1] <= x:
        print(len(S))
    else:
        end = len(S) - 1
        start = -1
        while end - start > 1:
            mid = (start + end) // 2
            if S[mid] > x:
                end = mid
            else:
                start = mid
        print(end)
0