結果

問題 No.1349 Subset Product Queries
ユーザー 👑 NachiaNachia
提出日時 2021-01-28 18:01:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 198,656 KB
実行使用メモリ 101,132 KB
最終ジャッジ日時 2023-09-08 09:13:31
合計ジャッジ時間 7,108 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 145 ms
94,316 KB
testcase_12 AC 135 ms
83,944 KB
testcase_13 AC 134 ms
83,976 KB
testcase_14 AC 139 ms
95,720 KB
testcase_15 AC 140 ms
89,624 KB
testcase_16 AC 143 ms
94,976 KB
testcase_17 AC 122 ms
83,328 KB
testcase_18 AC 83 ms
88,132 KB
testcase_19 AC 76 ms
87,892 KB
testcase_20 AC 133 ms
98,912 KB
testcase_21 AC 143 ms
101,132 KB
testcase_22 AC 126 ms
99,068 KB
testcase_23 AC 137 ms
101,132 KB
testcase_24 AC 118 ms
98,032 KB
testcase_25 AC 133 ms
100,056 KB
testcase_26 AC 150 ms
101,048 KB
testcase_27 AC 129 ms
99,240 KB
testcase_28 AC 129 ms
99,524 KB
testcase_29 AC 127 ms
99,376 KB
testcase_30 AC 134 ms
99,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    rep(p,P) dp[i+1][p]=dp[i][p];
    for(int p=0; p<P; p++){
      dp[i+1][to]=max(dp[i+1][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;
}
0