Advertisement
GerONSo

Untitled

Sep 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. int n;
  2. cin >> n;
  3. vi a(n), b(n);
  4. unordered_map<int, int> mp;
  5. for(int i = 0; i < n; i++) {
  6. cin >> a[i];
  7. b[i] = a[i];
  8. mp[a[i]] = 1;
  9. }
  10. sort(all(a));
  11. for(int i = 0; i < n; i++) {
  12. for(int j = 0; j < i; j++) {
  13. if(lower_bound(all(a), a[i] + a[j]) == a.end()) continue;
  14. if(a[lower_bound(all(a), a[i] + a[j]) - a.begin()] == a[i] + a[j]) mp[a[i] + a[j]]++;
  15. }
  16. }
  17. for(int i = 0; i < n; i++) {
  18. cout << mp[b[i]] - 1 << '\n';
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement