#include #include #include #include constexpr int MAX_K = 5000; int main() { int N, Q; std::scanf("%d %d", &N, &Q); std::vector A(N); for (auto &x: A) { std::scanf("%d", &x); } std::vector> dp(N + 1); for (auto &arr: dp) { arr.fill(-1); } dp[0][0] = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j <= MAX_K; ++j) { dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]); if (j + A[i] <= MAX_K) { dp[i + 1][j + A[i]] = std::max(dp[i + 1][j + A[i]], dp[i][j]); } } dp[i + 1][0] = i + 1; } while (Q--) { int l, r, k; std::scanf("%d %d %d", &l, &r, &k); l -= 1; if (dp[r][k] >= l) { std::puts("Yes"); } else { std::puts("No"); } } return 0; }