POJ1323 Game Prediction(贪心)
来源:互联网 发布:php实战视频教程百度云 编辑:程序博客网 时间:2024/04/30 14:44
题意:
m个人每人n张牌,每张牌的点数都不同,每轮每个人出一张牌,求最少能赢几轮的最大值。
要点:
很简单的贪心思想,因为问最少能赢几轮,所以假定自己出牌如果不是当前最大值,一定用人出比自己大的牌,这样只要将牌面从大到小排序,从大的开始出牌,与总共的牌进行比较,看有几张牌大于当前牌,再减去已经其中已经出过的牌,如果值为0就说明此轮能赢,如果不能赢就需要耗费一张大牌。
15954542Seasonal1323Accepted240K16MSC++469B2016-08-14 08:42:01#include<iostream>#include<algorithm>using namespace std;bool cmp(int a, int b){return a > b;}int main(){int n, m, kase = 1;int a[500];while (cin >> m >> n){if (n == 0 && m == 0)break;for (int i = 0; i < n; i++)cin >> a[i];sort(a, a + n,cmp);int p = n*m;int count = 0,temp=0;//temp用来存储前面已经出过的大牌for (int i = 0; i < n; i++){if (p-a[i]-i-temp==0)count++;elsetemp++;}printf("Case %d: %d\n", kase++, count);}return 0;}
0 0
- POJ1323 Game Prediction(贪心)
- POJ1323 Game Prediction(贪心)
- poj1323 Game Prediction 贪心
- POJ1323 Game Prediction(贪心)
- POJ1323 Game Prediction(贪心算法训练)
- poj1323(Game Prediction)
- POJ1323 Game Prediction
- POJ1323------Game Prediction
- poj1323 Game Prediction
- 【POJ1323】Game Prediction 博弈,或者说贪心(本博客用栈处理)
- Game Prediction(贪心)
- Game Prediction(贪心)
- POJ 1323-Game Prediction(贪心)
- poj Game Prediction 1323 (贪心ordp)
- 【贪心】Game Prediction
- 【贪心专题】POJ 1323 && HDU 1338 Game Prediction (贪心)
- POJ | 1323 Game Prediction | 贪心
- 贪心 hdu-1338-Game Prediction
- 性能优化之--MySql优化
- 落单的数 II
- spring框架概述及六大核心功能介绍
- Android开发高级技术自定义进度条(自定义progressbar)
- Java、Java SE、Java Web和Java EE的区别
- POJ1323 Game Prediction(贪心)
- How to Delete [This is no longer located in Directory] Files
- spring框架开发步骤详细解析
- mybatis的动态条件查询
- react native 首次运行时遇到的一个小问题(小米手机)
- 比如比较字符串、判断文件是否存在及是否可读等,通常用"[]"来表示条件测试。
- 信息安全相关需求分析
- JAVA的集合框架详解
- 身份证最后一位