//pku1323
//题目意思:
//m个人每人n张卡,每一轮一个出一张,点数大者胜一轮
//已知自己卡,求最少可胜几轮
#include<iostream>
using namespace std;
int main()
{
int n,m;
int t=1;
while(cin>>m>>n,n&&m)
{
int *num=new int[n*m+1];
memset(num,0,sizeof(num));
int *a=new int[n+1];
int i;
for(i=0;i<n;i++)
{
cin>>a[i];
num[a[i]]=1;
}
int cnt=0;
int temp=0;
int con=0;
for(i=n*m;i>0;i--)
{
if(num[i]==1)
{
if(temp>0)
{
temp--;
}
else cnt++;
}
else temp++;
}
cout<<"Case "<<t<<": "<<cnt<<endl;
t++;
}
return 0;
}
poj1323 Game Prediction 贪心
最新推荐文章于 2022-12-02 22:29:21 发布
本文解析了一道关于比赛策略的算法题,问题设定为多名玩家使用卡片进行比大小的游戏,目标是最小化获胜轮次。文章通过C++代码实现了解决方案,利用数组记录卡片点数分布,并遍历寻找最优策略。
150

被折叠的 条评论
为什么被折叠?



