about summary refs log tree commit diff
path: root/2ndary/09/TP-HN-2014/cau2.cpp
blob: 8c87168a7d9dc447ee242859c5f04768af51bc25 (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
#include <stdlib.h>
#include <iostream>
#include <fstream>

using namespace std;

int
main()
{
  ifstream infile;
  infile.open("CAU2.INP");
  short n, i, j;
  long d, count = 0;
  infile >> n >> d;
  short* v = (short*) malloc(n * sizeof(short));
  for (i = 0; i < n; i++)
    {
      infile >> v[i];
      for (j = 0; j < i; j++)
        if (d * (v[i] - v[j]) > v[i] * v[j] * (i - j))
          count++;
    }
  infile.close();
  free(v);

  ofstream outfile;
  outfile.open("CAU2.OUT");
  outfile << count << endl;
  outfile.close();

  return 0;
}