Jeopardy!

文章描述了一个简化版的Jeopardy!比赛,其中决赛包含常规问题和拍卖问题。玩家可以翻倍得分,目标是计算出最佳策略下的最高可能得分。输入输出格式说明了问题的数量、价值和拍卖问题的选择,以及解答的规则。示例展示了如何计算最大得分。
摘要由CSDN通过智能技术生成

Jeopardy!

题面翻译

题意简述

“Jeopardy!”的决赛将有n问题,每个问题都有对应的得分ai,其中有m个问题可以选择不得分,而将现有总得分翻倍。你可以安排关卡的通过顺序和策略,求最大得分。

输入输出格式

输入格式:

第一行包含两个整数。n和m(1<=n,m<=100;m<=min(n,30))分别代表问题总数和可翻倍问题总数。第二行包含n个整数a1,a2,…,an(1<=ai<=1e7)代表每个问题的价值;第三行包含m个整数b1,b2,…,bm(1<=bi<=n)代表可翻倍问题的编号。问题编号是从1到n。

输出格式:

一行一个数字,表示通过所有关卡最大得分。保证该答案在64位带符号整型范围内。

感谢@Peter_Matthew 提供的翻译

题目描述

‘Jeopardy!’ is an intellectual game where players answer questions and earn points. Company Q conducts a simplified ‘Jeopardy!’ tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 and company R2.

The finals will have $ n $ questions, $ m $ of them are auction questions and $ n-m $ of them are regular questions. Each question has a price. The price of the $ i $ -th question is $ a_{i} $ points. During the game the players chose the questions. At that, if the question is an auction, then the player who chose it can change the price if the number of his current points is strictly larger than the price of the question. The new price of the question cannot be less than the original price and cannot be greater than the current number of points of the player who chose the question. The correct answer brings the player the points equal to the price of the question. The wrong answer to the question reduces the number of the player’s points by the value of the question price.

The game will go as follows. First, the R2 company selects a question, then the questions are chosen by the one who answered the previous question correctly. If no one answered the question, then the person who chose last chooses again.

All R2 employees support their team. They want to calculate what maximum possible number of points the R2 team can get if luck is on their side during the whole game (they will always be the first to correctly answer questions). Perhaps you are not going to be surprised, but this problem was again entrusted for you to solve.

输入格式

The first line contains two space-separated integers $ n $ and $ m $ $ (1<=n,m<=100; m<=min(n,30)) $ — the total number of questions and the number of auction questions, correspondingly. The second line contains $ n $ space-separated integers $ a_{1},a_{2},…,a_{n} $ $ (1<=a_{i}<=10^{7}) $ — the prices of the questions. The third line contains $ m $ distinct integers $ b_{i} $ $ (1<=b_{i}<=n) $ — the numbers of auction questions. Assume that the questions are numbered from $ 1 $ to $ n $ .

输出格式

In the single line, print the answer to the problem — the maximum points the R2 company can get if it plays optimally well. It is guaranteed that the answer fits into the integer 64-bit signed type.

样例 #1

样例输入 #1

4 1
1 3 7 5
3

样例输出 #1

18

样例 #2

样例输入 #2

3 2
10 3 8
2 3

样例输出 #2

40

样例 #3

样例输入 #3

2 2
100 200
1 2

样例输出 #3

400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[110];
ll a[110];
ll res;
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> f[i],res+=f[i];
	for (int i = 1; i <= m; i++)
	{
		int t;
		cin >> t;
		a[i] = f[t];
	}
	sort(a + 1, a + m + 1);
	ll t=2;
	int i;
	for (i = 1; i <= m; i++)
	{
		if (res - a[i]>= res / 2)t *= 2,res-=a[i];
		else break;
	}
	cout << res * t / 2;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值