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 ...
随机推荐
- 关于Java基本数据类型
Java的基本数据类型分为两大类:boolean类型和数字类型.而数值类型又分为整数类型和浮点类型.而整数类型中的字符类型也可以被单独对待. 总共是4类8种. byte类型整数在内存里占8位. -12 ...
- js数组求和
array1.reduce(callbackfn[, initialValue]) callback : 函数执行在数组中每个值 initialValue : 对象作为第一个参数回调的第一次调用使用 ...
- [MSDN] 使用 SharePoint 2013 中的 JavaScript 库代码完成基本操作
MSDN:http://msdn.microsoft.com/zh-cn/library/jj163201.aspx 了解如何编写代码以在 SharePoint 2013 中使用 JavaScript ...
- session的介绍与简单使用
cookie由浏览器带着,容易被篡改因为cookie很容易被篡改,所以cookie用来记住用户名,记住浏览历史等安全性要求不高的地方可以用sessin技术session技术将信息存入服务器,然后再给客 ...
- orcale授权
grant connect,resource,dba to 表名;--用户授权 CONNECT角色: --是授予最终用户的典型权利,最基本的 CREATE SESSION --建立会话 RESOURC ...
- ASP连接11种数据库的常用语法
1.Access数据库的DSN-less连接方法: 以下为引用的内容: set adocon=Server.Createobject("adodb.connection") ado ...
- Java_Web_request.setAttribute("result",username);
request.setAttribute("result",username); 在request对象中加入名为result的属性并附值为username,因为request对象是 ...
- WCF编程系列(四)配置文件
WCF编程系列(四)配置文件 .NET应用程序的配置文件 前述示例中Host项目中的App.config以及Client项目中的App.config称为应用程序配置文件,通过该文件配置可控制程序的 ...
- IOS之swift第一课基础代码
import Foundation //import Foundation 导入模块,专业术语也是导入 包,库的 意思. var str = "Hello World" //声明一 ...
- Java多线程同步代码块
/*多线程的安全问题1.为什么会出现安全问题?因为程序在运行时,会出现一个线程在判断条件满足后,具备了执行资格,但没有运行代码后一个线程也判断了条件,也具备了执行资格,后一个线程运行了代码,但这时候, ...