結果
問題 | No.1349 Subset Product Queries |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-28 17:57:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 1,736 ms |
コンパイル使用メモリ | 193,796 KB |
最終ジャッジ日時 | 2025-01-18 08:32:00 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d%d%d",&N,&Q,&P); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:13:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | rep(i,N) scanf("%d",&A[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:24:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | int l,r,k; scanf("%d%d%d",&l,&r,&k); l--; | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>using namespace std;using LL=long long;using ULL=unsigned long long;#define rep(i,n) for(int i=0; i<(n); i++)int N,Q,P;int A[5000];int dp[5001][5000];int main(){scanf("%d%d%d",&N,&Q,&P);rep(i,N) scanf("%d",&A[i]);rep(i,N+1) rep(j,P) dp[i][j]=-1;for(int i=0; i<N; i++){int to=0;for(int p=0; p<P; p++){dp[i+1][to]=max(dp[i][to],dp[i][p]);to+=A[i]; if(to>=P) to-=P;}dp[i+1][A[i]]=i;}rep(q,Q){int l,r,k; scanf("%d%d%d",&l,&r,&k); l--;if(dp[r][k]>=l) printf("Yes\n"); else printf("No\n");}return 0;}