【小米OJ-最少交换次数】逆序对数

【小米OJ-最少交换次数】逆序对数

 

 

import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String line;
        while (scan.hasNextLine()) {
            line = scan.nextLine().trim();
            // please write your code here
            String str[] = line.split(",");
            int arr[] = new int[str.length];
            for(int i=0;i<arr.length;i++) arr[i] = Integer.parseInt(str[i]);
            int sum=0;
            for(int i=0;i<arr.length-1;i++)
                for(int j=i+1;j<arr.length;j++)
                     if(arr[i]>arr[j]) sum++;

            System.out.println(sum);
        }
    }

}

  

【小米OJ-最少交换次数】逆序对数

上一篇:Model class apps.goods.models.GoodsType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS


下一篇:AutoMapper 映射配置写法