fork download
  1. program ideone;
  2. var
  3. a:array[1..10] of String;
  4. b:array[1..10] of integer;
  5. i, N, j, k, r_s, tmp_b:integer;
  6. s, tmp_a:String[50];
  7. begin
  8. for i:=1 to 10 do begin
  9. b[i]:=0; a[i]:='';
  10. end;
  11. readln(N);
  12. for i:=1 to N do begin
  13. readln(s);
  14. for j:=1 to 10 do
  15. if (a[j]=s) then break;
  16. if ((j=10) AND (a[j]<>s)) then begin
  17. for k:=1 to 10 do
  18. if (a[k]='') then begin a[k]:=s; b[k]:=1; break; end;
  19. end
  20. else
  21. b[j]:=b[j]+1;
  22. end;
  23. r_s:=0;
  24. for i:=1 to 10 do
  25. if (a[i]='') then break
  26. else r_s:=r_s+1;
  27.  
  28. for i:=1 to r_s do begin
  29. for j:=i+1 to r_s do begin
  30. if (b[i]<b[j]) then begin
  31. tmp_b:=b[i]; b[i]:=b[j]; b[j]:=tmp_b;
  32. tmp_a:=a[i]; a[i]:=a[j]; a[j]:=tmp_a;
  33. end; end; end;
  34.  
  35. for i:=1 to r_s do
  36. writeln(a[i]);
  37.  
  38. end.
Success #stdin #stdout 0s 336KB
stdin
6
Party one
Party two
Party three
Party three
Party two
Party three
stdout
Party three
Party two
Party one