天天看点

HDOJ 2523 SORT AGAIN

HDACM 2523

暴力解决

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        while(c-->){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int x[] = new int[n];
            for (int i = ; i < x.length; i++) {
                x[i] = sc.nextInt();
            }
            boolean b[] = new boolean[];
            for (int i = ; i < x.length; i++) {
                for (int j = i+; j < x.length; j++) {
                    b[Math.abs(x[j]-x[i])]=true;
                }
            }
            int count = ;
            for (int i = ; i < b.length; i++) {
                if (b[i]) {
                    count++;
                    if (count==k) {
                        System.out.println(i);
                        break;
                    }
                }
            }
        }
        sc.close();
    }
}