6 条题解

  • 0
    @ 2025-12-2 17:32:40
    #include <iostream>
    using namespace std;
    int main(){
        int N;
        cin>>N;
        while(N--){
            int m;
            cin>>m;
            int att[m];
            for(int i=0;i<m;i++){
                cin>>att[i];
            }
            int max=att[0];
            for(int i=0;i<m;i++){
                if(att[i]>max){
                    max=att[i];
                }
            } 
            int app[max+1]={0};
            for(int i=0;i<m;i++){
                app[att[i]]++;
            }
            
            int maxa=app[0];
            int j=0;
            for(int i=0;i<max+1;i++){
                if(app[i]>maxa){
                    maxa=app[i];
                    j=i;
                }
            }
            cout<<j<<" "<<maxa;
            cout<<"\n";
        }
        return 0;
    }
    
    • 0
      @ 2025-11-12 20:15:12
      #include <stdio.h>
      int main(){
          int n;
          scanf("%d",&n);
          while(n--){
              int m,cnt,i=0,a[109],b[100009]={0};
              scanf("%d",&m);
              cnt=m;
              while(m--){
                  scanf("%d",&a[i]);
                  b[a[i]]++;
                  i++;
              }
              int max=0,num;
              for(i=0;i<cnt;i++){
                  if(b[a[i]]>max){max=b[a[i]];num=a[i];}
              }
              printf("%d %d\n",num,max);
          }
      }
      
      • 0
        @ 2025-11-8 2:13:04
        #include <iostream>
        using namespace std;
        int main(){
        	int t;
        	cin >> t;
        	while(t--){
        		int m;
        		cin >> m;
        		int a[100];
        		int tong[1000000]={0};
        		for(int i = 1 ; i <= m ; i++){
        			cin >> a[i];
        			tong[a[i]]++;
        		}
        		int max = 0;
        		int x;
        		for(int j = 1 ; j <= m ; j++){
        			if(tong[a[j]]>max){
        				max = tong[a[j]];
        				x = a[j];
        			}
        		}
        		cout << x <<" " <<max<<'\n';
        	}
        	return 0;
        }
        
        • 0
          @ 2025-9-13 17:11:37

          还是熟悉的Counter

          from math import sqrt, ceil, gcd, log;re = lambda: map(int, input().strip().split());from collections import Counter
          
          t, = re()
          for _ in range(t):
              n, = re()
              print(*Counter(re()).most_common(1)[0])
          
          • 0
            @ 2024-9-23 14:09:55

            #include<stdio.h> int main(){ int n,a,i,max,t; scanf("%d",&n); while(n--) { scanf("%d",&a); int arr[100]; int b[100001]={0}; for(i=0;i<a;i++) { scanf("%d",&arr[i]); b[arr[i]]++; } max=0; for(i=0;i<a;i++) { if(b[arr[i]]>max){ max=b[arr[i]]; t=arr[i]; } } printf("%d %d\n",t,max); }

            return 0;
            

            }

            • 0
              @ 2023-10-10 21:19:05
              #include <stdio.h>
              #include <string.h>
              
              #define N 100010
              
              int a[N];
              int main()
              {
                  int n, m, i, t, p, ans;
                  scanf("%d", &n);
                  while (n--)
                  {
                      memset(a, 0, sizeof(a));
                      ans = 0;
                      scanf("%d", &m);
                      for (i = 0; i < m; i++)
                      {
                          scanf("%d", &t);
                          a[t]++;
                      }
                      for (i = 0; i < N; i++)
                      {
                          if (a[i] > ans)
                          {
                              p = i;
                              ans = a[i];
                          }
                      }
                      printf("%d %d\n", p, ans);
                  }
                  return 0;
              }
              
              • 1

              信息

              ID
              158
              时间
              3000ms
              内存
              128MiB
              难度
              7
              标签
              (无)
              递交数
              1081
              已通过
              286
              上传者