比赛 20111110 评测结果 WWTTTTTTTT
题目名称 韩国明星 最终得分 0
用户昵称 wk_noi 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-11-10 10:52:25
显示代码纯文本
Program star(input,output);
Const
 maxn=100000;
Var
 n,i,j,k,l:longint;
 a:array[1..maxn]of string;
 b:array[1..maxn]of longint;
 s:string;

Procedure qsort(l,r:longint);
 var
  i,j,t:longint;
  s:string;
 begin
  if l<r then
   begin
    i:=l;
    j:=r;
    t:=b[i];
    s:=a[i];
    while i<j do
     begin
      while (i<j)and(t<b[j])do dec(j);
      if i<j then
       begin
        b[i]:=b[j];
        a[i]:=a[j];
        inc(i);
       end;
      while (i<j)and(t>b[i])do inc(i);
      if i<j then
       begin
        b[j]:=b[i];
        a[j]:=a[i];
        dec(j);
       end;
     end;
    a[i]:=s;
    b[i]:=t;
    qsort(l,i-1);
    qsort(i+1,r);
   end;
 end;

Begin
 assign(input,'star.in');
 assign(output,'star.out');
 reset(input);
 rewrite(output);
 readln(n);
 for i:=1 to n do
  begin
   readln(a[i]);
   b[i]:=0;
  end;
 readln(k);
 for i:=1 to k do
  begin
   readln(s);
   readln(l);
   for j:=1 to n do
    if s=a[j] then
     begin
      b[j]:=b[j]+l;
      break;
     end;
  end;
 qsort(1,n);
 for i:=1 to n do
  begin
   writeln(a[i]);
   writeln(b[i]);
  end;
 close(input);
 close(output);
End.