#pragma GCC optimize("O3", "unroll-loops") #pragma GCC target("avx") #include #include static constexpr int buffer_size = 1 << 17; static char buffer[buffer_size]; static int pos = buffer_size; inline char get_char(void){ if(pos == buffer_size){ fread_unlocked(buffer, 1, buffer_size, stdin); pos = 0; } return buffer[pos++]; } inline int getint(void){ int res = 0; char c; while((c = get_char() - '0') >= 0) res = 10 * res + c; return res; } inline void put_char(const char c){ if(pos == buffer_size){ fwrite_unlocked(buffer, 1, buffer_size, stdout); pos = 0; } buffer[pos++] = c; } char buffer2[20]; inline void println(int x){ if(x){ int idx = 0; do{ buffer2[idx++] = x % 10; x /= 10; } while(x); while(idx) put_char(buffer2[--idx] ^ '0'); } else put_char('0'); put_char('\n'); } constexpr int MAX_N = 100000; constexpr int MAX_Q = 100000; int A[MAX_N], S[MAX_N], X[MAX_N]; int main(void){ const int n = getint(), k = getint(); for(int i = 0; i < n; ++i) A[i] = getint();{ int val = 0; for(int i = 0; i < k; ++i) val += A[i]; for(int i = 0, j = k; j < n; ++i, ++j){ S[i] = val; val += A[j] - A[i]; } S[n - k] = val; } std::sort(S, S + n); const int q = getint(); for(int i = 0; i < q; ++i) X[i] = getint(); pos = 0; for(int i = 0; i < q; ++i){ const int res = std::lower_bound(S, S + n, X[i]) - S; println(res); } fwrite_unlocked(buffer, 1, pos, stdout); return 0; }