Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- i, j, k, c, t, p, s, max, maxsum: integer;
- mas: array[1..10, 1..4] of integer;
- zadach: array[1..10] of integer;
- ch, vr, pr, pr2: char;
- begin
- read(t, p);
- for i := 1 to p do
- read(zadach[i]);
- for i := 1 to t do
- for j := 1 to 4 do
- mas[i,j] := 0;
- readln(s);
- for i := 1 to s do begin
- readln(k, pr, ch, pr2, vr);
- if(vr = 'A') then begin
- inc(mas[k,1], zadach[ord(ch)-64]);
- inc(mas[k,2]);
- end;
- inc(mas[k,3]);
- end;
- c := 0; max := 1; maxsum := mas[1,1];
- while(c < t) do begin
- for i := 1 to t do
- if(mas[i,1] > maxsum) and (mas[i,4] <> 1) then begin maxsum := mas[i,1]; max := i end;
- for i := 1 to t do begin
- if(mas[i,1] = maxsum) and (max <> i) and (mas[i,4] <> 1) then begin
- if(mas[i,2] < mas[max,2]) then begin max := i; maxsum := mas[i,1];end
- else
- if(mas[i,2] = mas[max,2]) then begin
- if(mas[i,3] < mas[max,3]) then begin max := i; maxsum := mas[i,1];end
- end;
- end;
- end;
- writeln(max,' ', maxsum); inc(c); mas[max,4] := 1; maxsum := -1;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement