Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. var
  2. i, j, k, c, t, p, s, max, maxsum: integer;
  3. mas: array[1..10, 1..4] of integer;
  4. zadach: array[1..10] of integer;
  5. ch, vr, pr, pr2: char;
  6. begin
  7. read(t, p);
  8. for i := 1 to p do
  9. read(zadach[i]);
  10. for i := 1 to t do
  11. for j := 1 to 4 do
  12. mas[i,j] := 0;
  13. readln(s);
  14. for i := 1 to s do begin
  15. readln(k, pr, ch, pr2, vr);
  16. if(vr = 'A') then begin
  17. inc(mas[k,1], zadach[ord(ch)-64]);
  18. inc(mas[k,2]);
  19. end;
  20. inc(mas[k,3]);
  21. end;
  22. c := 0; max := 1; maxsum := mas[1,1];
  23. while(c < t) do begin
  24. for i := 1 to t do
  25. if(mas[i,1] > maxsum) and (mas[i,4] <> 1) then begin maxsum := mas[i,1]; max := i end;
  26. for i := 1 to t do begin
  27. if(mas[i,1] = maxsum) and (max <> i) and (mas[i,4] <> 1) then begin
  28. if(mas[i,2] < mas[max,2]) then begin max := i; maxsum := mas[i,1];end
  29. else
  30. if(mas[i,2] = mas[max,2]) then begin
  31. if(mas[i,3] < mas[max,3]) then begin max := i; maxsum := mas[i,1];end
  32. end;
  33. end;
  34. end;
  35. writeln(max,' ', maxsum); inc(c); mas[max,4] := 1; maxsum := -1;
  36. end;
  37. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement