ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1617. Flat Spots

WA8!!!
Posted by Dimaphil 8 Nov 2009 13:42
var a : array[1..150] of integer;
    n, i, j, k, m, t, l : integer;
begin
  readln(n);
  for i := 1 to n  do begin
    readln(a[i]);
  end;
  for i := 1 to n do begin
    for j := 1 to n - i do begin
      if a[j] < a[j + 1] then begin
        t := a[j];
        a[j] := a[j + 1];
        a[j + 1] := t;
      end;
    end;
  end;
  i := 2;
  k := 1;
  while i <= n do begin

    if a[i] = a[i - 1] then begin
      inc(k);
    end
    else begin
    inc(m);
    if k >= 4 then begin
      inc(l);
    end;
    k := 1;
    end;

    inc(i);

  end;
  l := l + (k div 4);
  writeln(l);
end.

Why is WA?