about summary refs log tree commit diff
path: root/2ndary/12/TP-ThanhHoá-2009/bai2.pas
blob: 5b43c06f4b178f318f07dcbe3e3a87e4bf8ed08e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var
  n: word;
  k, a: smallint;
  f: text;
  b: array[-999..999] of byte;


function libai2(): byte;
  var
    i: smallint;

  begin
    for i := -999 to k - 1 do
      if (b[i] > 0) and
         (b[k * 2 - i] > 0) then
        exit(1);

    if b[k] > 1 then
      exit(1);

    exit(0)
  end;


begin
  assign(f, 'BAI2.INP');
  reset(f);
  readln(f, n, k);
  fillchar(b, sizeof(b), 0);
  repeat
    read(f, a);
    inc(b[a]);
    dec(n)
  until n = 0;
  close(f);

  assign(f, 'BAI2.OUT');
  rewrite(f);
  writeln(f, libai2());
  close(f)
end.