結果

問題 No.1349 Subset Product Queries
ユーザー tnakao0123tnakao0123
提出日時 2021-01-21 13:19:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,178 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 91,684 KB
実行使用メモリ 100,332 KB
最終ジャッジ日時 2023-08-26 00:35:54
合計ジャッジ時間 17,911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,468 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1349.cc:  No.1349 Subset Product Queries - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5000;
const int MAX_P = 5000;

/* typedef */

/* global variables */

int as[MAX_N];
int dp[MAX_N + 1][MAX_P];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n, q, p;
  scanf("%d%d%d", &n, &q, &p);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  memset(dp[0], -1, sizeof(dp[0]));
  for (int i = 0; i < n; i++) {
    memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
    setmax(dp[i + 1][as[i]], i);

    for (int j = 0; j < p; j++)
      if (dp[i][j] >= 0)
	setmax(dp[i + 1][j * as[i]], dp[i][j]);
  }

  while (q--) {
    int li, ri, ki;
    scanf("%d%d%d", &li, &ri, &ki);
    li--;

    if (dp[ri][ki] >= li) puts("Yes");
    else puts("No");
  }

  return 0;
}
0