POJ 1018(多关键字排序还在wa…)
来源:互联网 发布:qq网络背景音乐链接 编辑:程序博客网 时间:2024/05/21 15:01
哪为朋友帮我看看多关键字排序哪儿错了……
Program P1018;type product=record b,id:longint; p:longint; end;var t,n,i,j,total,count,maxb,mintb,price:longint; visit:array[1..100] of longint; m:array[1..100] of longint; a:array[1..100000] of product; ans:double;function max(a,b:longint):longint;begin if a<b then exit(b) else exit(a);end;function min(a,b:longint):longint;begin if a>b then exit(b) else exit(a);end;procedure qsort(l,r:longint);var i,j:longint; m,p:product;begin i:=l; j:=r; m:=a[(l+r) div 2]; repeat while a[i].b<m.b do inc(i); // while (a[i].p<m.p) and (a[i].b=m.b) do inc(i); // while (a[i].id<m.id) and (a[i].b=m.b) and (a[i].p=m.p) do inc(i); while a[j].b>m.b do dec(j);// while (a[j].p>m.p) and (a[j].b=m.b) do dec(j);// while (a[j].id>m.id) and (a[j].b=m.b) and (a[j].p=m.p) do dec(j); if i<=j then begin p:=a[i]; a[i]:=a[j]; a[j]:=p; inc(i);dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r);end;begin { assign(input,'p1018.in'); assign(output,'p1018.out'); reset(input); rewrite(output); }read(t); while t>0 do begin total:=0; read(n); mintb:=maxlongint; for i:=1 to n do begin read(m[i]); maxb:=0; for j:=1 to m[i] do begin inc(total); a[total].id:=i; read(a[total].b,a[total].p); maxb:=max(a[total].b,maxb); end; mintb:=min(maxb,mintb); end; qsort(1,total); ans:=0; for i:=1 to total-n+1 do begin if a[i].b>mintb then break; count:=0; fillchar(visit,sizeof(visit),0); visit[a[i].id]:=a[i].p; for j:=i+1 to total do begin if a[j].b<a[i].b then write('x'); if (visit[a[j].id]=0) then begin inc(count); visit[a[j].id]:=a[j].p; end; visit[a[j].id]:=min(visit[a[j].id],a[j].p); end; if count<n-1 then break; price:=0; for j:=1 to n do inc(price,visit[j]); if ans<(a[i].b/price) then ans:=a[i].b/price; end; writeln(ans:3:3); dec(t); end;{ close(input); close(output); }end.
- POJ 1018(多关键字排序还在wa…)
- Linux 之sort-多关键字排序(在第一个关键字的基础上再进行第二个关键字排序)
- poj 1094 WA
- Poj 1008 总是WA
- !POJ 1154--DFS(WA了20次)
- POJ-1580(一直WA,没有找到原因)
- POJ-2501(用例能过,但一直WA)
- POJ-2562(用例能过,但一直WA)
- POJ-2575(用例能过,但一直WA)
- POJ-1065-Wooden Sticks-贪心-多关键字排序
- [转]POJ WA/RE指南
- **********POJ Calendar(不明白为什么WA)
- POJ 1112 WA到死
- 成绩排序(关键字排序)
- Q2007(WA->AC)
- hdu 2604(WA)
- wa
- WA~~~~~~~
- C# Lock 解读
- UVA10499-正义的土地
- POJ3159—糖果分配 差分约束系统实现
- UVA10719-多项式除法的商
- URL网络 编程
- POJ 1018(多关键字排序还在wa…)
- UtilBox(ub)基础组件 -- EasyCurl 发送http请求(2)
- UVA10790-多少个交点
- UVA10815-安迪的第一个字典
- 找技术资料的方法和注意事项
- UVA10875-疯狂的命理学家
- c# 自动更新设计
- 【hdu】 The Unique MST
- UVA10879代码重构