Movatterモバイル変換


[0]ホーム

URL:



Codeforces
In EnglishПо-русски
Enter |Register



Codeforces Round 995 (Div. 3)
Finished
→ Practice?
Want to solve the contest problems after the official contest ends? Just register for practice and you will be able to submit solutions.
→ Virtual participation
Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.
→ Problem tags
binary search
sortings
two pointers
*1200
No tag edit access
→ Contest materials
The problem statement has recently been changed.View the changes.
×
D. Counting Pairs
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a sequence $$$a$$$, consisting of $$$n$$$ integers, where the $$$i$$$-th element of the sequence is equal to $$$a_i$$$. You are also given two integers $$$x$$$ and $$$y$$$ ($$$x \le y$$$).

A pair of integers $$$(i, j)$$$ is consideredinteresting if the following conditions are met:

  • $$$1 \le i < j \le n$$$;
  • if you simultaneously remove the elements at positions $$$i$$$ and $$$j$$$ from the sequence $$$a$$$, the sum of the remaining elements is at least $$$x$$$ and at most $$$y$$$.

Your task is to determine the number ofinteresting pairs of integers for the given sequence $$$a$$$.

Input

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

Each test case consists of two lines:

  • The first line contains three integers $$$n, x, y$$$ ($$$3 \le n \le 2 \cdot 10^5$$$, $$$1 \le x \le y \le 2 \cdot 10^{14}$$$);
  • The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^{9}$$$).

Additional constraint on the input: the sum of $$$n$$$ across all test cases does not exceed $$$2 \cdot 10^5$$$.

Output

For each test case, output one integer — the number ofinteresting pairs of integers for the given sequence $$$a$$$.

Example
Input
7
4 8 10
4 6 3 6
6 22 27
4 9 6 3 4 5
3 8 10
3 2 1
3 1 1
2 3 4
3 3 6
3 2 1
4 4 12
3 3 2 1
6 8 8
1 1 2 2 2 3
Output
4700156
Note

In the first example, there are $$$4$$$interesting pairs of integers:

  1. $$$(1, 2)$$$;
  2. $$$(1, 4)$$$;
  3. $$$(2, 3)$$$;
  4. $$$(3, 4)$$$.


Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time:May/12/2025 07:05:31 (n2).
Desktop version, switch tomobile version.
Privacy Policy |Terms and Conditions
Supported by
TON
 
ITMO University
 
 
 
 
User lists
 
 
Name

[8]ページ先頭

©2009-2025 Movatter.jp