fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. const int N = 6e5 + 5;
  6. int n , k;
  7. int a[N];
  8. map < int , int > cnt;
  9.  
  10.  
  11. main()
  12. {
  13. ios::sync_with_stdio(0);
  14. cin.tie(0);
  15. cin >> n >> k;
  16. for(int i = 1 ; i <= n ; i++)
  17. cin >> a[i];
  18. /// x3 < x4
  19. int ans = 0;
  20. for(int x3 = 1 ; x3 <= n ; x3++)
  21. {
  22. for(int x4 = x3 + 1 ; x4 <= n ; x4++)
  23. ans += cnt[a[x3] + a[x4] + (int)3e5];
  24.  
  25. /// x1 < x2 = x3
  26. for(int x1 = 1 ; x1 <= x3 - 1 ; x1++)
  27. cnt[k - a[x1] - a[x3] + (int)3e5]++;
  28. }
  29. cout << ans << "\n";
  30.  
  31.  
  32. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
0