A13961 | Emotional Fishermen
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
$n$ fishermen have just returned from a fishing vacation. The $i$ -th fisherman has caught a fish of weight $a_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 $1$ to $n$ ). 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 $x$ , and the maximum weight of a previously shown fish is $y$ ( $y = 0$ if that fisherman is the first to show his fish). Then:
- if $x \ge 2y$ , the fisherman becomes happy;
- if $2x \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 $998244353$ .
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 $1$ to $n$ ). 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 $x$ , and the maximum weight of a previously shown fish is $y$ ( $y = 0$ if that fisherman is the first to show his fish). Then:
- if $x \ge 2y$ , the fisherman becomes happy;
- if $2x \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 $998244353$ .
输入格式
The first line contains one integer $n$ ( $2 \le n \le 5000$ ).
The second line contains $n$ integers $a_1$ , $a_2$ , ..., $a_n$ ( $1 \le a_i \le 10^9$ ).
The second line contains $n$ integers $a_1$ , $a_2$ , ..., $a_n$ ( $1 \le a_i \le 10^9$ ).
输出格式
Print one integer — the number of emotional orders, taken modulo $998244353$ .
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted