oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

difference Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

statement.html

Problem Description

Given a sequence of N integers, find the number of pairs of integers of difference exactly K.

The integers will range from 0 to D inclusive.

Input

The first line of input will contain 2 single integers, N and K

The next line will contain N integers, which describe the sequence.

Output

Output a single integer, the number of pairs of integers where their difference is exactly K.

Subtasks

Subtask 1 (10 points): N, K, D ≤ 1000

Subtask 2 (10 points): N, K, D ≤ 10000

Subtask 3 (20 points): N ≤ 100000, K, D ≤ 1000000

Subtask 4 (20 points): N ≤ 500000, K, D ≤ 1000000

Subtask 5 (40 points): N ≤ 1000000, K, D will fit into a 32-bit signed integer

Subtask 6 (0 points): Sample Testcases

For subtask 1,2 and 3 there will be no repeated numbers.

For subtask 4 and 5 there will be repeated numbers.

Sample Input

10 5
1 2 3 4 5 6 7 8 9 10

Sample Output

5

Tags

Data Structure

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1101001s64MBMinimum
2101001s64MBMinimum
3201001s64MBMinimum
420501s64MBMinimum
540211s64MBMinimum
6011s64MBMinimum

Judge Compile Command

g++-8 ans.cpp -o difference -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.