No.1093 Sum of Range
タグ : / 解いたユーザー数 123
作問者 :
null
/ テスター :
butsurizuki
Problem Statement
There is a sequence $a_1, a_2, \dots, a_N$.
Let $\displaystyle S_i = \sum_{j = i}^{i + K - 1} a_j = a_i + a_{i+1} + \dots + a_{i + K - 1}$, and let $S = \{S_1, S_2, \dots, S_{N-K + 1}\}$ be a multiset (added later).
For the $l(1 \le l \le Q)$-th query, output the number of elements of $S$ that are less than or equal to $x_l$.
In other words, output how many of $S_1, S_2, \dots, S_{N - K + 1}$ are less than or equal to $x_l$.
Input
$N\ K$ $a_1\ a_2\ \dots\ a_N$ $Q$ $x_1$ $x_2$ $\dots$ $x_Q$
$1 \le N, Q \le 10^5$
$-10^4 \le a_i \le 10^4$
$1 \le K \le N$
$-10^9 \le x_l \le 10^9$
All inputs are integers.
Output
Output the answers over $Q$ lines, separated by newlines. Print a newline at the end.
Sample
Sample 1
Input
10 2 1 2 3 4 5 6 7 8 9 10 10 19 18 17 15 13 11 9 7 5 3
Output
9 8 8 7 6 5 4 3 2 1
$S=\{3,5,7,9,11,13,15,17,19\}$.
Source
YSF Beginner Contest: F - 区間の和 / Sum of Range
writer: null
tester: butsuri_0523
Ported in accordance with HackerRank's terms. Some parts have been modified due to the circumstances of the site, among other reasons.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。