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\)的点,并将其删除 分析 看完傻眼 问 ...
随机推荐
- [React] Intro to inline styles in React components
React lets you use "inline styles" to style your components; inline styles in React are ju ...
- 内核代码架构图 :systemtap函数选择点
- INERT DELEYED、INSERT IGNORE replace into和insert区别
insert into表示插入数据,数据库会检查主键,如果出现重复会报错:replace into表示插入替换数据,需求表中有PrimaryKey,或者unique索引,如果数据库已经存在数据 ...
- Qt 学习之路:QML 基本元素
QML 基本元素可以分为可视元素和不可视元素两类.可视元素(例如前面提到过的Rectangle)具有几何坐标,会在屏幕上占据一块显示区域.不可视元素(例如Timer)通常提供一种功能,这些功能可以作用 ...
- eclipse删除空行
1.打开源码编辑器 2.使用快捷键Ctrl+f 3.在Find输入框中输入:^\s*\n 4.Replace With输入框的值为空 5.在[Options]选中的"Regular expr ...
- Java——(六)Collection之Queue集合
------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- Queue集合 Queue集合用于模拟队列这种数据结构,队列通常是指“先进先出‘(FIFO)的容 ...
- ubuntu环境配置之vi 配置【转载】
ubuntu环境配置之vi 配置 [日期:2014-02-10] 来源:Linux社区 作者:zhonghe1114 [字体:大 中 小] Android的源码开发,几乎离不开Linux,Lin ...
- Python之路【第十一篇】:CSS --暂无内容-待更新
Python之路[第十一篇]:CSS --暂无内容-待更新
- day-10
/* 还是习惯在插入里面写东西 233 今晚停电了 一屋人唱歌讲鬼故事 挺开心的 还有不到十天大家就要分开了 还记得第一次来机房的时候 大家都还不认识 到现在快一年了 大家可以一起闹一起笑 一起没心没 ...
- Android开发常见错误类型一览表
这是我的第一个博客,我会一直添加我在Android开发中遇到的错误,用来记录我开发中踩过的那些坑 ------------------------分割线------------------------ ...