結果
問題 | No.1349 Subset Product Queries |
ユーザー |
![]() |
提出日時 | 2021-01-11 21:20:45 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,391 bytes |
コンパイル時間 | 2,434 ms |
コンパイル使用メモリ | 113,192 KB |
最終ジャッジ日時 | 2025-01-17 16:13:36 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 1 WA * 29 |
ソースコード
#line 1 "main.cpp"/*** @title Template*/#include <iostream>#include <algorithm>#include <utility>#include <numeric>#include <vector>#include <array>#include <cassert>#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"class range {struct iter {std::size_t itr;constexpr iter(std::size_t pos) noexcept: itr(pos) { }constexpr void operator ++ () noexcept { ++itr; }constexpr bool operator != (iter other) const noexcept { return itr != other.itr; }constexpr std::size_t operator * () const noexcept { return itr; }};struct reviter {std::size_t itr;constexpr reviter(std::size_t pos) noexcept: itr(pos) { }constexpr void operator ++ () noexcept { --itr; }constexpr bool operator != (reviter other) const noexcept { return itr != other.itr; }constexpr std::size_t operator * () const noexcept { return itr; }};const iter first, last;public:constexpr range(std::size_t first, std::size_t last) noexcept: first(first), last(std::max(first, last)) { }constexpr iter begin() const noexcept { return first; }constexpr iter end() const noexcept { return last; }constexpr reviter rbegin() const noexcept { return reviter(*last - 1); }constexpr reviter rend() const noexcept { return reviter(*first - 1); }};/*** @title Range*/#line 15 "main.cpp"using i32 = std::int32_t;using i64 = std::int64_t;using u32 = std::uint32_t;using u64 = std::uint64_t;using isize = std::ptrdiff_t;using usize = std::size_t;constexpr i32 inf32 = (u32) ~0 >> 2;constexpr i64 inf64 = (u64) ~0 >> 2;template <class T>using Vec = std::vector<T>;int main() {usize N, Q;std::cin >> N >> Q;Vec<u32> A(N);for (auto &x: A) {std::cin >> x;}Vec<std::array<isize, 5001>> dp(N + 1);for (auto &arr: dp) {arr.fill(-1);}dp[0][0] = 0;for (auto i: range(0, N)) {for (auto j: range(0, 5001)) {dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);if (j + A[i] <= 5000) {dp[i + 1][j + A[i]] = std::max(dp[i + 1][j + A[i]], dp[i][j]);}}dp[i + 1][0] = (isize) (i + 1);}while (Q--) {usize l, r;u32 k;std::cin >> l >> r >> k;l -= 1;std::cout << (dp[r][k] >= (isize) l ? "Yes" : "No") << '\n';}return 0;}