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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. CF 371B Fox Dividing Cheese[数论]

    B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...

  4. CF 510b Fox And Two Dots

    Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on ...

  5. [CF #290-C] Fox And Names (拓扑排序)

    题目链接:http://codeforces.com/contest/510/problem/C 题目大意:构造一个字母表,使得按照你的字母表能够满足输入的是按照字典序排下来. 递归建图:竖着切下来, ...

  6. codeforces 388C Fox and Card Game

    刚刚看到这个题感觉是博弈题: 不过有感觉不像,应该是个贪心: 于是就想贪心策略: 举了一个例子: 3 3 1 2 3 4 3 4 1 2 5 4 1 2 5 8 如果他们两个每次都拿对自己最有利的那个 ...

  7. cf C. Fox and Box Accumulation

    题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...

  8. cf B. Fox Dividing Cheese

    http://codeforces.com/contest/371/problem/B #include <cstdio> #include <iostream> #inclu ...

  9. cf 512D - Fox And Travelling

    题目大意 给定一颗\(n\le 100\)个点的图,可以进行随机游走,求游走\(k=0...n\)个点的方案数 游走的规则是:每次只能访问一个度数\(\le 1\)的点,并将其删除 分析 看完傻眼 问 ...

随机推荐

  1. [React] React Fundamentals: with-addons - ReactLink

    It can be tedious to type out all the boilerplate needed to get the DOM and states in React to synch ...

  2. Qt 学习之路:QML 基本元素

    QML 基本元素可以分为可视元素和不可视元素两类.可视元素(例如前面提到过的Rectangle)具有几何坐标,会在屏幕上占据一块显示区域.不可视元素(例如Timer)通常提供一种功能,这些功能可以作用 ...

  3. Java基础知识强化之集合框架笔记23:ArrayList的实现原理

    1. ArrayList的实现原理: 这个可以直接参考网友的博客:http://www.cnblogs.com/ITtangtang/p/3948555.html

  4. C#压缩文件为zip格式

    Vercher   C#压缩文件为zip格式 需要ICSharpCode.SharpZipLib.dll,网上下载的到. 代码是从网上找来的: 1 public class ZipClass 2 { ...

  5. MD5 SHA-1 示例

    测试代码 public class SignatureUtils {     public static void main(String[] args) throws Exception {     ...

  6. Date和TimeZone的关系

    java2平台为我们提供了丰富的日期时间API.如java.util.Date;java.util.calendar;java.text.DateFormat等.那么它们之间有什么关系呢? 首先,ja ...

  7. 一次项目中用到的php函数总结

    最近做的一个项目,我把做的过程中用到的php函数总结一下.以后遇到类似的不用百度,直接看自己总结的就好了.都是一些简单基础的函数,随手记下.方便以后学习. 1.array_sum() 返回数组中的所有 ...

  8. updatepanel局部刷新功能,实现注册时对用户名的检测

    updatepanel的使用 通过将控件放入到updatepanel中,实现局部刷新. 前台代码:<asp:ScriptManager ID="ScriptManager1" ...

  9. Android Camera 流程梳理

    毕业已经快两年了,一直没有写博客的习惯,这是第一篇,以后要慢慢养成这个习惯.毕业之后一直在做相机,先简单的梳理下Android Camera的流程. Android Camera 是一个client/ ...

  10. 如何用visual studio控件(repeater)绑定数据库(SQL server)信息并显示

    今天学习了下如何间接绑定数据库网上看了很多信息,都云里雾里,没有图片说明,初学者完全看不懂,我自己做了一个DEMO,相信可以帮到大家! 一.建立数据库,并构建表信息,我的表信息如下: 表中的数据在数据 ...