cf E. Fox and Card Game
http://codeforces.com/contest/389/problem/E
题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的和尽可能大,最后输出两个人得到的数的和。
思路:如果序列的个数为偶数的话,前面一半为x所得,后面一半为y所得; 如果为奇数的话,中间的数根据它的大小决定谁得到。这样的处理方式因为两个人都尽可能的取得序列中的最大,在谁的那一半数大的,另一个人取不到,有的时候可以先放一放,去取别人即将取到的数。
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#define ll long long
#define maxn 1000
using namespace std; int n;
int x[maxn]; int main()
{
scanf("%d",&n);
int ans1=,ans2=;
int x,k;
vector<int>q;
while(n--)
{
scanf("%d",&k);
for(int i=; i<=k/; i++)
{
scanf("%d",&x);
ans1+=x;
}
if(k%)
{
scanf("%d",&x);
q.push_back(x);
}
for(int i=; i<=k/; i++)
{
scanf("%d",&x);
ans2+=x;
}
}
sort(q.begin(),q.end());
int cnt=;
for(int i=(int)q.size()-; i>=; i--)
{
if(cnt%==) ans1+=q[i];
else ans2+=q[i];
cnt++;
}
printf("%d %d\n",ans1,ans2);
return ;
}
cf E. Fox and Card Game的更多相关文章
- 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 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 ...
- CF 371B Fox Dividing Cheese[数论]
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...
- CF 510b Fox And Two Dots
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on ...
- [CF #290-C] Fox And Names (拓扑排序)
题目链接:http://codeforces.com/contest/510/problem/C 题目大意:构造一个字母表,使得按照你的字母表能够满足输入的是按照字典序排下来. 递归建图:竖着切下来, ...
- codeforces 388C Fox and Card Game
刚刚看到这个题感觉是博弈题: 不过有感觉不像,应该是个贪心: 于是就想贪心策略: 举了一个例子: 3 3 1 2 3 4 3 4 1 2 5 4 1 2 5 8 如果他们两个每次都拿对自己最有利的那个 ...
- cf C. Fox and Box Accumulation
题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...
- cf B. Fox Dividing Cheese
http://codeforces.com/contest/371/problem/B #include <cstdio> #include <iostream> #inclu ...
- cf 512D - Fox And Travelling
题目大意 给定一颗\(n\le 100\)个点的图,可以进行随机游走,求游走\(k=0...n\)个点的方案数 游走的规则是:每次只能访问一个度数\(\le 1\)的点,并将其删除 分析 看完傻眼 问 ...
随机推荐
- hadoop资料汇总(网上)
http://blog.csdn.net/fansy1990/article/list/3 全部是hadoop的,挺好. http://stackoverflow.com/ ...
- 我的第一个C语言程序 (A+B Problem)(cheney-yang)
第一个接触的C语言程序,是一个简单的A+B问题! 题目出处:http://acm.nyist.net/JudgeOnline/problem.php?pid=1 题目描述: 计算a+b的值 输入: ...
- Java——(一)一切都是对象
------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- 一.用引用操纵对象 在java中一切都被视为对象,但操纵的标识符实际上是对象的一个“引用”( ...
- AIX系统上压缩与解压文件
压缩. 命令格式: #tar -cvf (或xvf)+文件名+设备 C:是本地到其他设备 x:是其他设备到本地 r:是追加,比如打包时,将其他文件追加进来使用该参数. t:显示tar包里的内容,但还原 ...
- 类 Array Arraylist List Hashtable Dictionary
总结C# 集合类 Array Arraylist List Hashtable Dictionary Stack Queue 我们用的比较多的非泛型集合类主要有 ArrayList类 和 HashT ...
- bash: ./configure: 权限不够 怎么办?
configure没有执行权限 通过chmod给其加上x权限 chmod +x configure 再在该用户下执行 ./configure
- 无软驱加载raid驱动安装windows2003及其他微软操作系统
[转载]http://blog.zol.com.cn/2650/article_2649199.html [另一篇]http://www.blue1000.com/bkhtml/c159/2013-0 ...
- 12XML(可扩展标记语言)
XML:eXtensible Markup Language 什么是标记语言?什么是标记? 标记(Markup):文档中任何不想被打印输出的部分(不是真正的文档内容,联想读书时做的“读书笔记”,在旁边 ...
- 命令模式(Command)
1.本质: 封装请求 2.定义: 把一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化,对请求排队或记录请求日志,以及支持可撤销的操作 3.核心: 原本“行为请求者”和“行为执行者”是紧紧 ...
- 系统默认字体Mac OS,Windows,XP,Lunix
可查获的信息太少,目前得知的是以中文为例, OS : Helvetical,Lucida Grande(西文默认字体) Windows 7: Microsoft Yahei Xp : Simsun,T ...