USACO 1.3 Mixing Milk 程序

All tests OK.

{
ID:ceeji
PROB:milk
LANG:PASCAL
}
//By Ceeji
//Date: 2009-6-1
//Type: Sort
//Resource: USACO 1.3
Program milk;
Const
   fin='milk.in';
   fou='milk.out';
Type nm=record
          p,a:longint;
        end;
Var
   i,n,m,sum:longint;
   info:array[1..5000]of nm;
Procedure qsort(s,t:longint);
var tmp:nm;
    e,i,j:longint;
begin
    i:=s; j:=t; e:=info[random(t-s+1)+s].p;
    repeat
       while (is)and(info[j].p>e) do dec(j);
       if i<=j then
       begin
          tmp:=info[i]; info[i]:=info[j]; info[j]:=tmp;
          inc(i); dec(j);
       end;
    until i>j;
    if j>s then qsort(s,j);
    if i0 do
   begin
      if n>info[i].a then
      begin
         inc(sum,info[i].p*info[i].a);
         dec(n,info[i].a);
         inc(i);
      end
      else
      begin
         inc(sum,info[i].p*n); n:=0; break;
      end;
   end;
   writeln(sum);
   close(output);
end. 

题外话:我帮你整理了包括 AI 写作、绘画、视频(自媒体制作)零门槛 AI 课程 + 国内可直接顺畅使用的软件。想让自己快速用上 AI 工具来降本增效,辅助工作和生活?限时报名

当前页阅读量为: