SHARE
TWEET

E

tsypko Jun 2nd, 2020 562 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n;
  5. int a[5005];
  6. bool was[400015];
  7. int res;
  8.  
  9. int main(){
  10.     cin >> n;
  11.     for (int i = 0; i < n; i++) {
  12.         cin >> a[i];
  13.         int j;
  14.         for (j = 0; j < i; j++)
  15.             if (was[a[i] - a[j] + 200005]) break;
  16.         if (j < i)
  17.             res++;
  18.         for (j = 0; j <= i; j++)
  19.             was[a[i] + a[j] + 200005] = true;
  20.     }
  21.     cout << res << endl;
  22.     return 0;
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top