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\)的点,并将其删除 分析 看完傻眼 问 ...
随机推荐
- Android 图标上面添加提醒(一)使用Canvas绘制
版权声明:本文为博主原创文章,未经博主允许不得转载. 在我们开发一些如通讯录.社交等应用或者应用添加新功能模块时,会考虑在对应的图标上加上未读信息的数量,或者是新功能提醒的图标,这样不占太大空间还能达 ...
- android 08 AndroidManifest.xml
AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xm ...
- 廖雪锋笔记1---python变量类型
整型:a/b a//b a%b 浮点型:.2 字符串: "" '' r"" r'' '''...''' r'''...'''' 变量值共享:写时复制 NULL型 ...
- MapReduce 运行机制
Hadoop中的MapReduce是一个使用简单的软件框架,基于它写出来的应用程序能够运行在由上千个机器组成的大型集群上,并且以一种可靠容错并行处理TB级别的数据集. 一个MapReduce作业(jo ...
- python s12 day2
python s12 day2 入门知识拾遗 http://www.cnblogs.com/wupeiqi/articles/4906230.html 基本数据类型 注:查看对象相关成员 var, ...
- easyui 常用代码
最近在公司制作内部使用数据管理网页,用到了easyui,使用过程中发现与jquery的写法有比较多不一样的地方,趁现在有空,先做个笔记. (这里主要说明的是combobox的用法,其他的像textbo ...
- int? 参数是这个的时候 是可以传入null的 而int的就不行
such as pager.CurrentPageIndex = (page != null ? (int)page : 1);
- sql - 获取日期中的年
使用 YEAR函数, 如 --day为rain表中的字段. select YEAR(day) from t_rain
- PIL安装记录,编译支持jpeg png
PIL是python理想的图片处理module,但是想要良好的支持各种图片,还需要检查一下几步,否则会提示:IOError: decoder jpeg not available之类的. 我的环境:L ...
- 删除我的电脑中360随身WiFi云U盘的图标
可通过删除注册表的方法 运行-regedit 找到这个项 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\My ...