結果

問題 No.1349 Subset Product Queries
ユーザー KoD
提出日時 2021-01-13 18:04:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 56,940 KB
最終ジャッジ日時 2025-01-17 17:27:15
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 1 WA * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     std::scanf("%d %d", &N, &Q);
      |     ~~~~~~~~~~^~~~~~~~~~~~~~~~~
main.cpp:13:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         std::scanf("%d", &x);
      |         ~~~~~~~~~~^~~~~~~~~~
main.cpp:31:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         std::scanf("%d %d %d", &l, &r, &k);
      |         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <cstdio>
#include <vector>
#include <array>
#include <algorithm>
constexpr int MAX_K = 5000;
int main() {
int N, Q;
std::scanf("%d %d", &N, &Q);
std::vector<int> A(N);
for (auto &x: A) {
std::scanf("%d", &x);
}
std::vector<std::array<int, MAX_K + 1>> 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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0