bzoj3983
显然我们得到这样几个结论
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的更多相关文章
随机推荐
- github 中删除/更名版本库(repository)
问题描述: github 中版本库创建/删除/更该名称 问题解决: (1)创建版本库(Repository) 注: 在上图中的+按钮图标指示的是创建版本库的按钮 注 ...
- 阿里云CentOS6.3 安装MongoDB教程
安装说明 系统环境:Centos-6.3安装软件:mongodb-linux-x86_64-2.2.2.tgz下载地址:http://www.mongodb.org/downloads安装机器:192 ...
- 使用shell脚本获取虚拟机中cpu使用率(读/proc/statc)
#!/bin/bash interval= cpu_num=`-] -c` start_idle=() start_total=() cpu_rate=() cpu_rate_file=./`host ...
- Python 资源
转:http://www.360doc.com/content/16/0308/14/31385575_540482688.shtml 本页面是俺收集的各种 Python 资源,不定期更新. 下面列出 ...
- 8个月从CS菜鸟到拿到Google Offer的经历+内推
http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=77453&page=1&authorid=10377 ...
- 在mac上安装hadoop伪分布式
换了macbook pro之后,要重新安装hadoop,但是mac上的jdk跟windows上的不同,导致折腾了挺久的,现在分享出来,希望对大家有用. 一:下载jdk 选择最新版本下载,地址:http ...
- C#中 ? 和?? 的用法
C#中 ?? 和? 的意思 1.? 如果直接定义一个 值类型,给负值null:就会提示“无法将 Null转换成‘值类型(比如:int)’,因为他是一种不可为null的值 de类型” 例如 int in ...
- hdu 1517 A Multiplication Game 博弈论
思路:求必胜区间和必败区间! 1-9 先手胜 10-2*9后手胜 19-2*9*9先手胜 163-2*2*9*9后手胜 …… 易知右区间按9,2交替出现的,所以每次除以18,直到小于18时就可以直接判 ...
- hdu2717 Catch That Cow
http://acm.hdu.edu.cn/showproblem.php?pid=2717 //水搜... #include<stdio.h> #include<math.h> ...
- [转]Ubuntu alternate和desktop区别
原文地址:http://blog.csdn.net/is2120/article/details/6797621 Desktop : 刻录在光盘,从光盘运行的系统,相当于 Live CD Altern ...