about summary refs log tree commit diff
path: root/2ndary/09/TP-HN-2014/cau2.pas
blob: aed61edf3e7a33935e4b062ee0c1458fffc3030b (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
var
  f: text;
  n, i, j: smallint;
  d: longint;
  v: array of smallint;
  t: array of real;

begin
  assign(f, 'CAU2.INP');
  reset(f);
  readln(f, n, d);
  setlength(v, n);
  for i := 0 to n - 1 do
    read(f, v[i]);
  close(f);

  setlength(t, n);
  for i := 0 to n - 1 do
    t[i] := i + d / v[i];

  d := 0;
  for i := 1 to n - 1 do
    for j := 0 to i - 1 do
      if t[i] < t[j] then
        inc(d);

  assign(f, 'CAU2.OUT');
  rewrite(f);
  writeln(f, d);
  close(f)
end.