fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int a[n], b[n], c[n], d[n], e[n];
  8. for(int i = 0; i < n; i++)
  9. cin >> a[i];
  10. for(int i = 0; i < n; i++)
  11. cin >> b[i];
  12. for(int i = 0; i < n; i++)
  13. cin >> c[i];
  14. for(int i = 0; i < n; i++)
  15. cin >> d[i];
  16. for(int i = 0; i < n; i++)
  17. cin >> e[i];
  18.  
  19. unordered_map<int,int> mp;
  20. for(int l = 0; l < n; l++){
  21. for(int m = 0; m < n; m++){
  22. mp[d[l]+e[m]]++;
  23. }
  24. }
  25. int cnt = 0;
  26. for(int i = 0; i < n; i++){
  27. for(int j = 0; j < n; j++){
  28. for(int k = 0; k < n; k++){
  29. int sum = a[i]+b[j]+c[k];
  30. int req = -1*sum;
  31. if(mp.find(req) != mp.end()){
  32. cnt += mp[req];
  33. }
  34. }
  35. }
  36. }
  37. cout << cnt;
  38. return 0;
  39. }
Success #stdin #stdout 0s 5312KB
stdin
2
2 5
3 8
-5 8
5 10
-10 100
stdout
2