主页
试题仓库
题目列表
试题分类
经典教材
竞赛作业
竞赛列表
提交状态
图灵学院
TuringMOOC
图灵书屋
图灵商城
图灵实验室
图灵会员
历史荣誉
支持我们
图灵IDE
用户/排名
AOJ排名
实名认证
请登录
常用链接
AOJ考试平台
老赵的Gitee代码
编译原理模拟考试平台
Java技术手册
FCC网站
菜鸟网
在线工具箱
字节豆包GPT
代码可视化
力扣网
牛客网
洛谷
杭电OJ
CodeForce
隐藏编译器
Problem 3028 --Stay Real
3028: Stay Real
上一题
正确率: $0.00\%$
下一题
Time Limit
$1$ 秒/Second(s)
Memory Limit
$512$ 兆字节/Megabyte(s)
提交总数
$1$
正确数量
$0$
"
裁判形式
标准裁判/Standard Judge
我的状态
尚未尝试
难度
分类标签
uuue
×
为本题添加算法分类(请不要超过5个)
当前分类(单击移除):
uuue
单击选择分类:
Description
<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">In computer science, a heap is a specialized tree-based data structure which is essentially an almost complete tree that satisfies the heap property: in a min heap, for any given node </span>CC<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, if </span>PP<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> is a parent node of </span>CC<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, then the key(the value) of </span>PP<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> is less than or equal to the key of </span>CC<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">. The node at the ``top'' of the heap(with no parents) is called the root node. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">Usually, we may store a heap of size </span>nn<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> in an array </span>h1,h2,…,hnh1,h2,…,hn<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, where </span>hihi<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> denotes the key of the </span>ii<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">-th node. The root node is the </span>11<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">-th node, and the parent of the </span>i(2≤i≤n)i(2≤i≤n)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">-th node is the </span>⌊i2⌋⌊i2⌋<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">-th node. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">Sunset and Elephant is playing a game on a min heap. The two players move in turns, and Sunset moves first. In each move, the current player selects a node which has no children, adds its key to this player's score and removes the node from the heap. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">The game ends when the heap is empty. Both players want to maximize their scores and will play optimally. Please write a program to figure out the final result of the game.</span>
Input
<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">The first line of the input contains an integer </span>T(1≤T≤10000)T(1≤T≤10000)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, denoting the number of test cases. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">In each test case, there is one integer </span>n(1≤n≤100000)n(1≤n≤100000)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> in the first line, denoting the number of nodes. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">In the second line, there are </span>nn<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> integers </span>h1,h2,...,hn(1≤hi≤109,h⌊i2⌋≤hi)h1,h2,...,hn(1≤hi≤109,h⌊i2⌋≤hi)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, denoting the key of each node. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">It is guaranteed that </span>∑n≤106∑n≤106<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">.</span>
Output
<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">For each test case, print a single line containing two integers </span>SS<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> and </span>EE<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, denoting the final score of Sunset and Elephant.</span>
Sample Input
1 3 1 2 3
Sample Output
4 2
推荐代码
查看3028 所有题解
上传题解视频得图灵币
本题记录
用 户(点击查看用户)
运行号(点击购买题解)
时 间
算法最快[$0 $ms]
0
内存最少[$0 $KB]
0
第一AC
0
第一挑战
0
赛题来源
2019 Multi-University Training Contest 6
AOJ
Please Login