Algorithm/ct/l2/14-Ruby和薯条.py

16 lines
274 B
Python
Raw Normal View History

2022-10-28 02:37:25 +08:00
import io
import sys
sys.stdin = io.StringIO('''5 2 3
3 1 6 2 5''') # 4
n, l, r = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n - 1):
for j in range(i + 1, n):
if l <= abs(a[i] - a[j]) <= r:
s += 1
print(s)