Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define int long long
  5. int a[6000];
  6. bool used[2000000];
  7. vector <int> q;
  8. main()
  9. {
  10. set<int> s;
  11. int n, kol = 0, kol2 = 1e6;
  12. cin >> n;
  13. for(int i =0 ; i < n; i++){
  14. cin >> a[i];
  15. if(a[i] < 0){
  16. if(used[abs(a[i]) + kol2]) kol++;
  17. }
  18. else{
  19. if(used[a[i]]) kol ++;
  20. }
  21. if(s.find(a[i]) == s.end()){
  22. q.push_back(a[i]);
  23. for(int j = 0; j < q.size(); j++){
  24. for(int o = 0; o < q.size(); o++){
  25. int h = a[i] + q[j] + q[o];
  26. if(h >= 0 )used[h] = 1;
  27. else used[abs(h)+ kol2] =1;
  28. }
  29. }
  30. s.insert(a[i]);
  31. }
  32. }
  33. cout << kol;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement