fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long arr[100005]; /// global declaration for large array
  4. int main()
  5. {
  6. int T;
  7. scanf("%d",&T); /// input test
  8. for(int cs=1; cs<=T; cs++){
  9. int n;
  10.  
  11. scanf("%d",&n); /// input number of elements
  12.  
  13. for(int i=0; i<n; i++){
  14. scanf("%lld",&arr[i]); /// input all elements
  15. }
  16.  
  17. sort(arr,arr+n); /// sort all elements
  18.  
  19. int cnt = 0;
  20. for(int i=0; i<n; i++){
  21. if(i==0) cnt++; /// handle the first element
  22. else if(arr[i]!=arr[i-1]) cnt++; /// count without duplicate
  23. }
  24.  
  25. printf("Case %d: %d\n",cs,cnt); /// print output
  26.  
  27.  
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Time limit exceeded #stdin #stdout 5s 4240KB
stdin
Standard input is empty
stdout
Standard output is empty