PASS


用学校 z/k的人看成绩 看那些在50%内

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
        int x = sc.nextInt();
        while (x-- > 0) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int k = sc.nextInt();
            int arr[] = new int[n];
            int sum[] = new int[m + 1];
            int count[] = new int[m + 1];
            int i = 0;
            int res = 0;
            for (; i < n / 2; ++i) {
                arr[i] = sc.nextInt();
                sum[arr[i]]++;
                count[arr[i]]++;
            }
            for (; i < n; i++) {
                arr[i] = sc.nextInt();
                count[arr[i]]++;
            }
            for(int i1 = 1 ; i1<= m ; i1++) {
                int temp = count[i1]/k;
                if(temp>=sum[i1])
                    res+=sum[i1];
                else if(temp<sum[i1])
                    res+=temp;
            }
            System.out.println(res);
        }
    }
}
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务