题解:
将任务放在x轴上,任务代价即为两点之间的距离,所以无论有多少个任务,最小代价是数轴上最大和最小点的距离
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String str = cin.nextLine();
String[] s = str.split(" ");
int[] arr = new int[s.length];
for (int i = 0; i < s.length; i++) {
arr[i] = Integer.parseInt(s[i]);
}
Arrays.sort(arr);
System.out.println(arr[2]-arr[0]);
}
}