比赛 20091110 评测结果 WWWWWWWWWW
题目名称 股票收益 最终得分 0
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-10 09:58:20
显示代码纯文本
program stock;
 const
   maxn = 1000;
 var
   n:   longint;
   M:           extended;
   maxvalue:    extended;
   ans:         longint;
   price:       array[1..maxn] of extended;


procedure init;
 var
   i:   longint;
 begin
   readln(n);
   for i :=1 to n do read(price[i]);
   readln(M);
 end;

procedure main;
 var
   i,j: longint;
   max,tmp: extended;
 begin
   maxvalue :=0;

   for i :=1 to n-1 do begin
       max :=0;
       for j :=i+1 to n do
           if price[j] >max then max :=price[j];
       tmp :=M/price[i]*(max - price[i]);
       if tmp >maxvalue then maxvalue :=tmp;
       end;
   writeln(maxvalue:0:3);

   for i :=1 to n-1 do
       for j :=i+1 to n do if price[i] <price[j]
           then inc(ans);
   writeln(ans/(n*(n-1) div 2):0:3);
 end;



begin
  assign(input,'stock.in');  reset(input);
  assign(output,'stock.out'); rewrite(output);
  init;
  main;
  close(input);  close(output);
end.