Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- signed main()
- {
- int t , n , l , r;
- cin >> t;
- while(t--){
- cin >> n >> l >> r;
- vector<int> a(n);
- for(int i = 0; i < n; i++){
- cin >> a[i];
- }
- sort(a.begin() , a.end());
- int ans = 0;
- for(int i = 0; i < (n - 1); i++){
- int g = l - a[i];
- int x = lower_bound(a.begin() , a.end() , g) - a.begin();
- g = r - a[i];
- int y = upper_bound(a.begin() , a.end() , g) - a.begin() - 1;
- x = max(x , i + 1);
- if(y >= x)
- ans += (y - x + 1);
- }
- cout << ans << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement