아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Prom

면접 대비

시간 제한1초메모리 제한128 MB

요약
두 명의 키 목록이 주어질 때 키 차이가 k 이하인 남녀 쌍의 수를 센다.
난이도

보통10점 중 4점

유형
정렬, 투 포인터, 이분 탐색
정답자
아직 제출이 없습니다

문제

Johnny is getting ready for prom, which traditionally begins with a polonnaise dance. Any mixed pair (boy and girl) can lead the polonnaise, as long as they do not differ too much in height. More precisely, the difference in their heights cannot exceed kk byteometers. Jimmy wants to find out how many ways there are to choose the leading pair.

Write a program which reads the heights of all girls and boys, computes the number of possible leading pairs, and writes the result to standard output.

입력

The first line of input contains three space-separated integers nn, mm and kk (1≤n,m≤250,0001 \le n, m \le 250\\,000, 0≤k≤1,000,000,0000 \le k \le 1 \\,000\\,000\\,000), denoting the number of girls, the number of boys and the maximum possible difference of height in the leading pair, respectively.

The second line of input contains a sequence of nn space-separated integers a_ia\_i (1≤a_i≤1,000,000,0001 \le a\_i \le 1\\,000\\,000\\,000): the heights of girls, given in byteometers.

The third line of input contains a sequence of mm space-separated integers b_ib\_i (1≤b_i≤1,000,000,0001 \le b\_i \le 1\\,000\\,000\\,000): the heights of boys, given in byteometers.

출력

The first and only line of output should contain a single integer --- the number of possible leading pairs.

힌트

There are 1111 possible leading pairs: (15,10)(15,10), (15,15)(15,15), (1,1)(1,1), (1,5)(1,5), (1,1)(1,1), (5,1)(5,1), (5,5)(5,5), (5,10)(5,10), (5,1)(5,1), (7,5)(7,5) and (7,10)(7,10).

예제1

  1. 예제 1

    입력
    4 5 5
    15 2 5 7
    1 5 10 15 1
    
    예상 출력
    11