A13625 | Circular Dungeon
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are creating a level for a video game. The level consists of $n$ rooms placed in a circle. The rooms are numbered $1$ through $n$ . Each room contains exactly one exit: completing the $j$ -th room allows you to go the $(j+1)$ -th room (and completing the $n$ -th room allows you to go the $1$ -st room).
You are given the description of the multiset of $n$ chests: the $i$ -th chest has treasure value $c_i$ .
Each chest can be of one of two types:
- regular chest — when a player enters a room with this chest, he grabs the treasure and proceeds to the next room;
- mimic chest — when a player enters a room with this chest, the chest eats him alive, and he loses.
The player starts in a random room with each room having an equal probability of being chosen. The players earnings is equal to the total value of treasure chests he'd collected before he lost.
You are allowed to choose the order the chests go into the rooms. For each $k$ from $1$ to $n$ place the chests into the rooms in such a way that:
- each room contains exactly one chest;
- exactly $k$ chests are mimics;
- the expected value of players earnings is minimum possible.
Please note that for each $k$ the placement is chosen independently.
It can be shown that it is in the form of $\frac{P}{Q}$ where $P$ and $Q$ are non-negative integers and $Q \ne 0$ . Report the values of $P \cdot Q^{-1} \pmod {998244353}$ .
You are given the description of the multiset of $n$ chests: the $i$ -th chest has treasure value $c_i$ .
Each chest can be of one of two types:
- regular chest — when a player enters a room with this chest, he grabs the treasure and proceeds to the next room;
- mimic chest — when a player enters a room with this chest, the chest eats him alive, and he loses.
The player starts in a random room with each room having an equal probability of being chosen. The players earnings is equal to the total value of treasure chests he'd collected before he lost.
You are allowed to choose the order the chests go into the rooms. For each $k$ from $1$ to $n$ place the chests into the rooms in such a way that:
- each room contains exactly one chest;
- exactly $k$ chests are mimics;
- the expected value of players earnings is minimum possible.
Please note that for each $k$ the placement is chosen independently.
It can be shown that it is in the form of $\frac{P}{Q}$ where $P$ and $Q$ are non-negative integers and $Q \ne 0$ . Report the values of $P \cdot Q^{-1} \pmod {998244353}$ .
输入格式
The first contains a single integer $n$ ( $2 \le n \le 3 \cdot 10^5$ ) — the number of rooms and the number of chests.
The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ( $1 \le c_i \le 10^6$ ) — the treasure values of each chest.
The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ( $1 \le c_i \le 10^6$ ) — the treasure values of each chest.
输出格式
Print $n$ integers — the $k$ -th value should be equal to the minimum possible expected value of players earnings if the chests are placed into the rooms in some order and exactly $k$ of the chests are mimics.
It can be shown that it is in the form of $\frac{P}{Q}$ where $P$ and $Q$ are non-negative integers and $Q \ne 0$ . Report the values of $P \cdot Q^{-1} \pmod {998244353}$ .
It can be shown that it is in the form of $\frac{P}{Q}$ where $P$ and $Q$ are non-negative integers and $Q \ne 0$ . Report the values of $P \cdot Q^{-1} \pmod {998244353}$ .
输入输出样例
输入 #1
2 1 2
输出 #1
499122177 0
输入 #2
8 10 4 3 6 5 10 7 5
输出 #2
499122193 249561095 249561092 873463811 499122178 124780545 623902721 0
In the first example the exact values of minimum expected values are: $\frac 1 2$ , $\frac 0 2$ .
In the second example the exact values of minimum expected values are: $\frac{132} 8$ , $\frac{54} 8$ , $\frac{30} 8$ , $\frac{17} 8$ , $\frac{12} 8$ , $\frac 7 8$ , $\frac 3 8$ , $\frac 0 8$ .
In the second example the exact values of minimum expected values are: $\frac{132} 8$ , $\frac{54} 8$ , $\frac{30} 8$ , $\frac{17} 8$ , $\frac{12} 8$ , $\frac 7 8$ , $\frac 3 8$ , $\frac 0 8$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted