fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. vector<bool> a(202, false);
  8.  
  9. int n, diffNum, curVal;
  10.  
  11. cin >> n;
  12.  
  13. diffNum = n;
  14.  
  15. for(int i = 0; i < n; i++)
  16. {
  17. cin >> curVal;
  18.  
  19. if(a[curVal + 100])
  20. {
  21. diffNum--;
  22. cout << " RED ALLERT >> Seen Num --> " << curVal << " <--" << "\n";
  23. }
  24. else
  25. {
  26. a[curVal + 100] = true;
  27. cout << " New num " << curVal << "\n";
  28. }
  29. }
  30.  
  31. cout << " << Total diffNum >> " << diffNum << endl;
  32.  
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 4272KB
stdin
7
3 5 -7 7 5 -9 -4
stdout
 New num  3
 New num  5
 New num  -7
 New num  7
 RED ALLERT >> Seen Num  --> 5 <--
 New num  -9
 New num  -4
 << Total diffNum >>  6