CF1437F.Emotional Fishermen

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

nn fishermen have just returned from a fishing vacation. The ii-th fisherman has caught a fish of weight aia_i.

Fishermen are going to show off the fish they caught to each other. To do so, they firstly choose an order in which they show their fish (each fisherman shows his fish exactly once, so, formally, the order of showing fish is a permutation of integers from 11 to nn). Then they show the fish they caught according to the chosen order. When a fisherman shows his fish, he might either become happy, become sad, or stay content.

Suppose a fisherman shows a fish of weight xx, and the maximum weight of a previously shown fish is yy (y=0y = 0 if that fisherman is the first to show his fish). Then:

  • if x≥2yx \ge 2y, the fisherman becomes happy;
  • if 2x≤y2x \le y, the fisherman becomes sad;
  • if none of these two conditions is met, the fisherman stays content.

Let's call an order in which the fishermen show their fish emotional if, after all fishermen show their fish according to this order, each fisherman becomes either happy or sad. Calculate the number of emotional orders modulo 998244353998244353.

nn 位渔民刚刚结束钓鱼假期归来。第 ii 位渔民捕获了一条重量为 aia_i 的鱼。

渔民们打算向彼此炫耀自己捕获的鱼。为此,他们首先确定一个展示鱼的顺序(每位渔民恰好展示一次自己的鱼,因此,从形式上讲,该展示顺序是整数 11 到 nn 的一个排列)。然后,他们按照选定的顺序依次展示各自捕获的鱼。当一位渔民展示他的鱼时,他可能变得开心、变得悲伤,或保持平静。

假设某位渔民展示了一条重量为 xx 的鱼,而此前已展示过的鱼的最大重量为 yy(若该渔民是第一位展示鱼的人,则 y=0y = 0)。那么:

  • 若 x≥2yx \ge 2y,则该渔民变得开心;
  • 若 2x≤y2x \le y,则该渔民变得悲伤;
  • 若上述两个条件均不满足,则该渔民保持平静。

我们称一个渔民展示鱼的顺序为情绪化顺序(emotional order),当且仅当所有渔民按该顺序展示完各自的鱼后,每位渔民都要么变得开心,要么变得悲伤(即无人保持平静)。请计算情绪化顺序的总数,并对 998244353998244353 取模。

输入格式

The first line contains one integer nn (2≤n≤50002 \le n \le 5000).

The second line contains nn integers a1a_1, a2a_2, ..., ana_n (1≤ai≤1091 \le a_i \le 10^9).

第一行包含一个整数 nn(2≤n≤50002 \le n \le 5000)。

第二行包含 nn 个整数 a1a_1、a2a_2、...、ana_n(1≤ai≤1091 \le a_i \le 10^9)。

输出格式

Print one integer — the number of emotional orders, taken modulo 998244353998244353.

输出一个整数——情感排列的数量,对 998244353998244353 取模。

输入输出样例

  • 输入#1

    4
    1 1 4 9

    输出#1

    20
  • 输入#2

    4
    4 3 2 1

    输出#2

    0
  • 输入#3

    3
    4 2 1

    输出#3

    6
  • 输入#4

    8
    42 1337 13 37 420 666 616 97

    输出#4

    19200

输入解题思路,AI测评打分。不知道怎么写?

首页