显然我们得到这样几个结论

1.每次攻击对方一定是攻击最大的

2.自己合并也是合并最大和次大的

我们只要穷举下一开始是攻击还是合并,之后就是能攻击先攻击否则就合并

 type node=array[..] of int64;

 var a,b,c,d:node;
j,i,n,m,t1,t2:longint; procedure qsort(var a:node; n:longint);
procedure sort(l,r: longint);
var i,j:longint;
x,y:int64;
begin
i:=l;
j:=r;
x:=a[(l+r) div ];
repeat
while a[i]<x do inc(i);
while x<a[j] do dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; begin
sort(,n);
end; procedure pre;
begin
c:=a;
d:=b;
n:=t1; m:=t2;
end; function work:boolean;
var turn:boolean;
begin
turn:=true;
while true do
begin
if n= then exit(false);
if m= then exit(true);
if turn then
begin
if (c[n]>d[m]) and (m>) then
begin
dec(m);
d[m]:=d[m]+d[m+];
d[m+]:=;
end
else if c[n]<d[m] then
begin
c[n]:=;
dec(n)
end
else exit(true);
end
else begin
if (c[n]>d[m]) then
begin
d[m]:=;
dec(m);
end
else if (c[n]<d[m]) and (n>) then
begin
dec(n);
c[n]:=c[n]+c[n+];
c[n+]:=;
end
else exit(false);
end;
turn:=not turn;
end;
end; function check:boolean;
var fl:boolean;
begin
check:=false;
if a[t1]>b[t2] then
begin
pre;
d[m]:=;
dec(m);
fl:=work;
if fl then exit(true);
end;
if t1> then
begin
pre;
dec(n);
c[n]:=c[n]+c[n+];
c[n+]:=;
fl:=work;
if fl then exit(true);
end;
end; begin
while not eof do
begin
inc(j);
readln(t1,t2);
for i:= to t1 do
read(a[i]);
for i:= to t2 do
read(b[i]);
readln;
qsort(a,t1);
qsort(b,t2);
write('Case ',j,': ');
if check then writeln('Takeover Incorporated')
else writeln('Buyout Limited');
end;
end.

bzoj3983的更多相关文章

随机推荐

  1. 一点关于Ajax和一个等待图标的显示

    一点关于Ajax和一个等待图标的显示 1.首先Ajax是asynchronous Java-Script and XML的简写.翻译过来就是异步的JS和XML. 2它的优点就是能不更新页面的情况下,得 ...

  2. 高德开发 android 出现 key 鉴权失败

    环境windows + android studio 原因: 曾经更改过key.store 解决办法: 首先运行cmd移动到keystore的目录下keytool -list -keystore 文件 ...

  3. Hadoop集群中pig工具的安装过程记录

    在Hadoop环境中安装了pig工具,安装过程中碰到了一些问题,在此做一下记录:   主要安装流程参考:http://www.cnblogs.com/yanghuahui/p/3768270.html ...

  4. Codeforces Round #363 (Div. 2)->C. Vacations

    C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. uva 11489

    简单博弈 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #i ...

  6. Oracle 9 - 分析undo和snapshot too old错误

    什么操作会生成undo INSERT生成的UNDO最少,只要记录新的rowid UPDATE生成的undo多一点,它要记录修改前的数据中的那部分. DELETE生成最多的undo, 因为它要记录整行被 ...

  7. 深入理解JVM—字节码执行引擎

    原文地址:http://yhjhappy234.blog.163.com/blog/static/3163283220122204355694/ 前面我们不止一次的提到,Java是一种跨平台的语言,为 ...

  8. python 常用数据结构使用

    python 字典操作 http://www.cnblogs.com/kaituorensheng/archive/2013/01/24/2875456.html python 字典排序 http:/ ...

  9. 如何实现Windows Phone代码与Unity相互通信(直接调用)

    我之前用了两篇文章写了WP与Unity相互通信.调用的办法,一个是事件,一个是插件. 这次来说个更简单的,我觉得这应该是Unity发布到WP或者Win Store上得天独厚的优势.毕竟都是C#. 懒得 ...

  10. 微信开发之——Php批量生成带参数的二维码

    带参数的二维码对于渠道营销推广来说是很有用的,可以获得多个带不同场景值的二维码,用户扫描后,公众号可以接收到事件推送,可喜的是微信开通了这个接口,那下面就来研究一下吧. 具体接口说明请参见,微信公众平 ...