bzoj 1034 伪田忌赛马
来源:互联网 发布:苍老师高清种子源码 编辑:程序博客网 时间:2024/06/04 04:39
其实,它就是田忌赛马的那个套路=。=
能赢不平,能平不输
先都排序,
然后小的能赢就让它赢,小的赢不了的话就去看大的,大的能赢就赢呗=。=
然后小的也赢不了大的也也不了就让小的输给他一个大的(注意判断一下平局)反正小的也没用,大的还可以赢
得出最大得分=。=
易知,无论双方输赢如何,n局的双方总得分是一定的即2*n 分,所以最小的分=2*n-对方最大得分
var n,ans :longint; i,j,k,l :longint; a,b :array[0..100010] of longint;procedure sort1(l,r:longint);var i,j,x,y: longint;begin i:=l; j:=r; x:=a[(l+r) div 2]; 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-1; end; until i>j; if l<j then sort1(l,j); if i<r then sort1(i,r);end;//procedure sort2(l,r:longint);var i,j,x,y: longint;begin i:=l; j:=r; x:=b[(l+r) div 2]; repeat while b[i]<x do inc(i); while x<b[j] do dec(j); if not(i>j) then begin y:=b[i];b[i]:=b[j];b[j]:=y; inc(i);j:=j-1; end; until i>j; if l<j then sort2(l,j); if i<r then sort2(i,r);end;begin read(n); for i:=1 to n do read(a[i]); for i:=1 to n do read(b[i]); sort1(1,n); sort2(1,n); // i:=1;j:=1;l:=n;k:=n;ans:=0; while (i<=l) and (j<=k) do begin if (a[i]>b[j]) then begin inc(i);inc(j);inc(ans,2); end else if (a[l]>b[k]) then begin dec(l);dec(k);inc(ans,2); end else begin if (a[i]=b[k]) then inc(ans); inc(i);dec(k); end; end; write(ans,' '); // ans:=0; i:=1;j:=1;l:=n;k:=n; while (i<=l) and (j<=k) do begin if (b[j]>a[i]) then begin inc(ans,2);inc(i);inc(j); end else if (b[k]>a[l]) then begin inc(ans,2);dec(l);dec(k); end else begin if b[j]=a[l] then inc(ans); inc(j);dec(l); end; end; writeln(2*n-ans);end.——by Eirlys
转载请注明出处=w=
0 0
- bzoj 1034 伪田忌赛马
- BZOJ 1034([ZJOI2008]泡泡堂BNB-田忌赛马)
- [BZOJ 1034][ZJOI2008]泡泡堂BNB(类田忌赛马贪心)
- bzoj 1034 n [ZJOI2008]泡泡堂BNB 贪心 田忌赛马
- BZOJ 1034: [ZJOI2008]泡泡堂BNB 贪心 田忌赛马
- [BZOJ]1034 [ZJOI2008]泡泡堂BNB (田忌赛马策略贪心)
- 赛马
- 赛马
- 赛马
- 赛马
- 赛马
- 赛马问题
- 赛马问题
- 赛马问题
- 赛马问题
- 赛马问题
- 赛马问题
- 赛马问题
- 老号被盗 这是我新号
- codeforce 735 C. Tennis Championship (斐波那契数列||网球比赛)
- Netty之源码下载
- 栈 实现四则运算的计算器
- 第十六周项目1 (1)——冒泡排序
- bzoj 1034 伪田忌赛马
- 使用su - root出现Authentication failure
- 遇到CUICatalog: Invalid asset name supplied: (null)
- Unity Mirror Reflection
- 关于ListView中包含EditText数据复用引起异常的解决方案
- hdu 2852
- Unity Mesh
- 使用su - root出现Authentication failure
- Windows7 64位下Keras的安装和配置