fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. scanf("%d", &n);
  6.  
  7. for (int i = 0; i < n; i++) {
  8. int people, count[100001]={0}, count1[100001]={0}, a, result = -1;
  9.  
  10. scanf("%d", &people);
  11. for (int p = 0; p < people; p++) {
  12. scanf("%d", &a);
  13. count[a]+=1;
  14. if (count[a] > people / 2) {
  15. result = a;
  16. }
  17. }
  18.  
  19. printf((result >= 0) ? "%d\n" : "SYJKGW\n", result);
  20. }
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5308KB
stdin
4 
10 1 2 3 1 2 3 1 2 3 1
5 1 1 1 2 2
6 10 10 2 10 10 2
6 1 1 1 2 2 2 
stdout
SYJKGW
1
10
SYJKGW