刚刚看到这个题感觉是博弈题;

不过有感觉不像,应该是个贪心;

于是就想贪心策略;

举了一个例子:

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

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

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

  3. CodeForces 462B Appleman and Card Game(贪心)

    题目链接:http://codeforces.com/problemset/problem/462/B Appleman has n cards. Each card has an uppercase ...

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

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

  6. codeforces 510B. Fox And Two Dots 解题报告

    题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...

  7. cf E. Fox and Card Game

    http://codeforces.com/contest/389/problem/E 题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的 ...

  8. Codeforces 388A - Fox and Box Accumulation

    388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...

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

随机推荐

  1. Ubuntu Linux---控制用户权限:root特权/sudo

    借了本<Ubuntu Linux指南>开始学学乌邦图吧,熟悉之后再下个红帽来玩玩,现在说说我们一直提到的root,但是在Linux中,这个root有所不同...大多数Linux系统都为一个 ...

  2. 【推理】UVa 10771 - Barbarian tribes

      Barbarian tribes  In a lost land two primitive tribes coexist: Gareds and Kekas. Every summer sols ...

  3. 汉诺塔的问题:4个柱子,如果塔的个数变位a,b,c,d四个,现要将n个圆盘从a全部移到d,移动规则不变

    四柱汉诺塔问题的求解程序.解题思路:如a,b,c,d四柱. 要把a柱第n个盘移到目标柱子(d柱),先把上层 分两为两部份,上半部份移到b柱,下半部分移到c柱,再把第n盘移到 目标柱子,然后,c柱盘子再 ...

  4. HTTP 错误 500.21 - Internal Server Error的解决方案

    开始菜单>所有程序>附件>命令提示符(以管理员的身份运行) 然后运行下面的命令注册: 32位机器: C:\Windows\Microsoft.NET\Framework\v4.0.3 ...

  5. Android——获取网络图片

    布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...

  6. Brackets 配置

    插件 Brackets Icons  左侧导航的文件图标 FuncDocr  注释工具 QuickDocsJS  js帮助文档 Beautify  格式化代码 Brackets Git  git支持 ...

  7. (三)JAVA使用POI操作excel

    1,单元格对齐方式 Demo8.java package com.wishwzp.poi; import java.io.FileOutputStream; import java.util.Date ...

  8. javascript 事件 第23节

    <html> <head> <title>DOM对象</title> <style type="text/css"> t ...

  9. Apache(一)

    以下介绍是基于centos,Apache/2.2.15,进行解释 (资料来自www.netcraft.com) Apache 模块化的软件 Apache=core+module(内核+模块) core ...

  10. Linux下GPIO驱动(三) ----gpio_desc()的分析

    上篇最后提出的疑问是结构体gpio_chip中的成员函数set等是怎么实现的,在回答之前先介绍下gpio_desc这个结构体. 如上图所示,右上方部分为GPIO驱动对其它驱动提供的GPIO操作接口,其 ...