fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void init(){
  5. cin.tie(0);
  6. cin.sync_with_stdio(0);
  7. }
  8. int main()
  9. {
  10. init();
  11. unsigned long long n , m , count1=0 ;
  12. cin >>n >>m;
  13. long long a[n];
  14. for (int i=0 ; i<n ; i++)
  15. cin >>a[i];
  16. for (int i=0 ; i<n ; i++){
  17. for (int j=i+1 ; j<n ; j++){
  18. if (a[i]==a[j])
  19. continue;
  20. else
  21. count1++;
  22. } }
  23. cout <<count1;
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5284KB
stdin
7 4
4 2 3 1 2 4 3
stdout
18