比赛 20111110 评测结果 AATTTTTTTT
题目名称 韩国明星 最终得分 20
用户昵称 Launcher 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-11-10 11:07:14
显示代码纯文本
program star;
var
 a:array[1..100000]of longint;
 s:array[1..100000]of string;
 t:string;
 i,j,k,m,n,max,x,y:longint;
 procedure qsort(l,r:longint);
 var i,j,x,t:longint; e:string;
 begin
   i:=l;
   j:=r;
   x:=a[(l+r)div 2];
   repeat
     while a[i]>x do inc(i);
     while a[j]<x do dec(j);
     if not(i>j) then
      begin
       t:=a[i];
       a[i]:=a[j];
       a[j]:=t;

       e:=s[i];
       s[i]:=s[j];
       s[j]:=e;

       inc(i);
       dec(j);
      end;

   until i>j;
   if l<j then qsort(l,j);
   if r>i then qsort(i,r);
 end;
begin
 assign(input,'star.in');reset(input);assign(output,'star.out');rewrite(output);
 readln(n);
 for i:=1 to n do
  readln(s[i]);
 readln(m);
 for i:=1 to m do
   begin
    readln(t);
    readln(x);
    for j:=1 to n do
     if t=s[j] then a[j]:=a[j]+x;
   end;
 qsort(1,n);
 for i:=1 to n do
  begin
    writeln(s[i]);
    writeln(a[i]);
  end;
 close(input);close(output);
end.