------
## 最终结论
```python
from sortedcontainers import SortedList

def containsNearbyAlmostDuplicate(nums, k, t):
    if t < 0: 
        return False
    
    window = SortedList()
    
    for i in range(len(nums)):
        if i > k:
            window.remove(nums[i - k - 1])
        
        pos1 = SortedList.bisect_left(window, nums[i] - t)
        pos2 = SortedList.bisect_right(window, nums[i] + t)
        
        if pos1 != pos2:
            return True
        
        window.add(nums[i])
    
    return False
```