codeforces 388C Fox and Card Game
刚刚看到这个题感觉是博弈题;
不过有感觉不像,应该是个贪心;
于是就想贪心策略;
举了一个例子:
3
3 1 2 3
4 3 4 1 2
5 4 1 2 5 8
如果他们两个每次都拿对自己最有利的那个的话,C的得分是14分;
但是C作为第一个选手,他有更好的策略,只拿前一半,后一半给J,中间的再分;这样的话C的得分就能达到15分;
同样J也有这样的策略,他也能保证自己最少能拿到后一半的分(跟风式的拿);
这样的话,贪心策略就明朗了!
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 105
using namespace std; int s[maxn];
int c,j;
int main()
{
int n,num;
int t,cnt=;
scanf("%d",&n);
for(int i=; i<n; i++)
{
scanf("%d",&t);
for(int k=; k<t/; k++)
{
scanf("%d",&num);
c+=num;
}
if(t&)
{
scanf("%d",&s[cnt]);
cnt++;
}
for(int k=; k<t/; k++)
{
scanf("%d",&num);
j+=num;
}
}
sort(s,s+cnt);
bool flag=;
for(int i=cnt-; i>=; i--)
{
if(flag)
c+=s[i];
else
j+=s[i];
flag=!flag;
}
printf("%d %d",c,j);
return ;
}
codeforces 388C Fox and Card Game的更多相关文章
- Codeforces 388C Fox and Card Game (贪心博弈)
Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her fr ...
- Codeforces Round #228 (Div. 1) C. Fox and Card Game 博弈
C. Fox and Card Game 题目连接: http://codeforces.com/contest/388/problem/C Description Fox Ciel is playi ...
- CodeForces 462B Appleman and Card Game(贪心)
题目链接:http://codeforces.com/problemset/problem/462/B Appleman has n cards. Each card has an uppercase ...
- CodeForces - 512B Fox And Jumping[map优化dp]
B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- CodeForces 388A Fox and Box Accumulation (模拟)
A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...
- codeforces 510B. Fox And Two Dots 解题报告
题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...
- cf E. Fox and Card Game
http://codeforces.com/contest/389/problem/E 题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的 ...
- Codeforces 388A - Fox and Box Accumulation
388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...
- CodeForces - 510B Fox And Two Dots (bfs或dfs)
B. Fox And Two Dots time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- PS定位
一.定位:按标准看谁离得近来进行覆盖:什么都没有(最远).浮动(远).定位(近) 二.position absolute 绝对定位,能堆叠在上一层下面,脱离文档流 relative 相对定位,按 ...
- Java事务处理总结
http://lavasoft.blog.51cto.com/62575/53815/ 一.什么是Java事务 通常的观念认为,事务仅与数据库相关. 事务必须服从ISO/IEC所制定的ACID ...
- APPlication,Session,Cookie,ViewState和Cache之间的区别
1.Application:用于保存所有用户共用的数据信息. 在Asp.Net中类似的配置数据最好保存在Web.config文件中.如果使用Application对象,一个需要考虑的问题是任何写操作都 ...
- Fluent Validation For .NET
//.net 中数据验证,一个开源的项目,直接下载 1 using FluentValidation; public class CustomerValidator: AbstractValidato ...
- php上传文件大小限制
和你的配置文件有关.改一下PHP配置文件php.ini给你总结下相关配置,自己去改吧 1.php.ini:upload_max_filesize 所上传的文件的最大大小.默认值2M. 2.php.in ...
- cisco通过控制口或者通过远程配置交换机
学而不思则罔,思而不学则殆,每天坚持一小步,则成功一大步 下面我们通过Cisco Packet来模拟交换机和路由器的远程和控制台登录配置交换机. 交换机console口的连接与配置方法 (1),在Ci ...
- C# Generic(转载)
型(generic)是C#语言2.0和通用语言运行时(CLR)的一个新特性.泛型为.NET框架引入了类型参数(type parameters)的概念.类型参数使得设计类和方法时,不必确定一个或多个具体 ...
- redis 实践—— sorted set, hash set
在这里就不谈redis的安装与启动啦,网上太多人写这个了. 从最近的一个项目[钻石夺宝]说起,如果大家有玩过一元夺宝或者全名夺宝的话,大概会知道如果参与人数多的话,每隔几秒.快的话每隔一秒都会新生成一 ...
- Java实战之04JavaWeb-01Servlet
一.Http协议 1.什么是http协议? http协议就是描述客户端与服务器端交互过程的 2.http的请求 3.http的响应 二.Servlet的简介 1.Servlet的概述 Servlet: ...
- virtual析构函数的作用
C++ Primter中讲“在 C++ 中,基类必须指出希望派生类重写哪些函数,定义为 virtual 的函数是基类期待派生类重新定义的,基类希望派生类继承的函数不能定义为虚函数”. 析构函数是为了在 ...