fork download
  1. // بسم الله الرحمن الرحيم
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { for (auto& i : v) os << i << ' '; return os; }
  7. template<typename T> istream& operator>>(istream& is, vector<T>& v) { for (auto& i : v) is >> i; return is; }
  8.  
  9. #define FreePalestine ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
  10.  
  11. #define endl '\n'
  12. #define int long long
  13. #define ull unsigned long long
  14. #define vi vector<int>
  15. #define vvi vector<vi>
  16. #define pi pair<int, int>
  17. #define all(a) a.begin(), a.end()
  18. #define all_r(a) a.rbegin(), a.rend()
  19.  
  20. const int N = 2e5, oo = 2e18, MOD = 1e9+7;
  21.  
  22. void solve() {
  23. int n, x, y; cin >> n >> x >> y;
  24. vi a(n); cin >> a;
  25. int sum = 0;
  26. for (int i = 0; i < n; i++) {
  27. sum += a[i];
  28. }
  29. sort(all(a));
  30. int ans = 0;
  31. for (int i = 0; i < n; i++) {
  32. auto l = lower_bound(a.begin() + i + 1, a.end(), sum - a[i] - y);
  33. auto r = upper_bound(a.begin() + i + 1, a.end(), sum - a[i] - x);
  34. ans += (r-l);
  35. }
  36. cout << ans << endl;
  37. }
  38.  
  39.  
  40. signed main() {
  41. FreePalestine;
  42. // #ifndef ONLINE_JUDGE
  43. // freopen("input.txt", "r", stdin);
  44. // freopen("output.txt", "w", stdout);
  45. // #endif
  46. int t; t = 1;
  47. cin >> t;
  48. while (t--) solve();
  49. return 0;
  50. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
0