import java.util.Scanner;
 
 
class Solution {
    static int Answer;
 
    public static void main(String args[]) throws Exception {
         
         
        Scanner sc = new Scanner(System.in);
         
        for(int T=1; T <=10; T++) {
             
            // dump 횟수
            int dumpCount = sc.nextInt();
            sc.nextLine();
             
            // 숫자 리스트
            String[] strNumList = sc.nextLine().trim().split(" ");
            int[] countArr = new int[101]; // 0 ~ 100
             
            // 각각의 숫자들을 카운팅
            int min=101, max=0;
            for(String strNum : strNumList) {
                int height = Integer.parseInt(strNum);
                countArr[height]++;
            }
             
             
            for(int j=0; j<=dumpCount; j++) {
                // 최대값 스캔
                for(int k=100; k>=0; k--) {
                    if(countArr[k] != 0) {
                        max = k;
                        break;
                    }
                }
                 
                // 최소값 스캔
                for(int k=0; k<=100; k++) {
                    if(countArr[k] != 0) {
                        min = k;
                        break;
                    }
                }
                 
                if(j!=dumpCount) {
                    // 블록옴기기 ( 0 ~ dumpCount-1 까지)
                    countArr[max]--;
                    countArr[max-1]++;
                    countArr[min]--;
                    countArr[min+1]++;
                }
            }
             
             
            // 높이차 출력
            System.out.println(String.format("#%d %d", T, max-min) );
             
        }
         
    }
}


import java.util.Scanner;
 
 
class Solution {
    static int Answer;
 
    public static void main(String args[]) throws Exception {
         
         
        Scanner sc = new Scanner(System.in);
         
        for(int T=1; T <=10; T++) {
            int size = sc.nextInt();
            int[] inputList = new int[size];
            for(int i=0; i <size ;i++) {
                inputList[i] = sc.nextInt();
            }
             
            // i 번째 조망권 (양옆 2이 배열범위에 벗어나지 않았을 떄 가정)
            int viewCount = 0;
            for(int i=0; i<size ; i++) {
                int left_2 = i-2 >= 0 ? inputList[i-2] : 0;
                int left_1 = i-1 >= 0 ? inputList[i-1] : 0;
                int right_1 = i + 1 < size ? inputList[i+1] : 0;
                int right_2 = i + 2 < size ? inputList[i+2] : 0;
                 
                int max = left_2;
                if(max < left_1) {max = left_1;}
                if(max < right_1) {max = right_1;}
                if(max < right_2) {max = right_2;}
                 
                viewCount += inputList[i] > max ? inputList[i]-max : 0;
            }
             
            System.out.println(String.format("#%d %d", T, viewCount) );
        }
         
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;


public class Main {
	
	public static void main(String[] args) {
		
		InputStream in = System.in;
		Reader isr = new InputStreamReader(in);
		BufferedReader br = new BufferedReader(isr);
		
		String[] input;
		int whatNumber = 0;
		int minlength = 0;
		try {
			input = br.readLine().split(" ");
			whatNumber = Integer.parseInt(input[0]);
			minlength = Integer.parseInt(input[1]);
		} catch (IOException e) {
			// e.printStackTrace();
		} 
		
		for(int i=minlength ; i <=100 ; i++) {
			
			if(getSolution(i, whatNumber)) {
				// log("getSolution(%d, %d)", i, whatNumber);
				printAnswear(i, whatNumber);
				break;
			}
			if(i==100) {
				log("-1");
			}
		}
		
	}

	// n : n 개의 연속 되는 수
	public static boolean getSolution(int n, int result) {
		// n = 1 일 때      k (단, k는 자연수 ) 
		// n = 2 일 때     2k + 1
		// n = n 일 때  nk + n(n-1)/2
		
		// result = nk + n(n-1)/2
		// result - n(n-1)/2 = nk
		// [result - n(n-1)/2] % n == 0 이라면 k정수가 존재
		
		int x = result - n*(n-1)/2;
		if(x < 0) {
			return false;
		}
		
		boolean okay = (x % n == 0) ;
		
		return okay;
	}

	public static void printAnswear(int n, int result) {
		int first = (result - n*(n-1)/2) / n;
		
		String Str = "";
		for(int i=0; i<n; i++) {
			Str += String.format("%d ", first+i);
		}
		System.out.println(Str.trim());
	}
	
	public static void log(String input) {	System.out.println(input);	}

	public static void log(String input, Object ...args) {
		System.out.println(String.format(input, args));
	}
	
}


+ Recent posts