Task Description
小芙來到了一個充滿寶箱怪的地下城,不巧的是寶箱怪正好是小芙的天敵,小芙總是會被寶箱怪困住,看來要通關這個地下城看來需要花上一些時間。
這個地下城總共有N個寶箱怪,每個寶箱怪都有自己的血量數值(blood),小芙每秒可以對怪物造成自身攻擊力(attack)的傷害,若怪物的血量小於等於0則死去。
小芙可以自由選擇要先與哪一隻寶箱怪戰鬥,不必按照順序。
小芙一開始的攻擊力為1,每打倒一隻寶箱怪後就會增加buff點的攻擊力(假設buff=1,小芙在第3秒時擊倒了第一隻血量為3的寶箱怪,在第4秒的時候小芙就能夠對另外一隻寶箱怪造成 1+1 = 2點的傷害)。
小芙在攻略完迷宮後還必須要帶著甜點回家,請你幫小芙算出最快幾秒鐘可以打倒所有寶箱怪,攻略地下城!
Hint
123456789101112131415161718192021222324252627 void swap(int* x, int* y) { int temp; temp = *x; *x = *y; *y = temp;} void time_computation(int *ans, int* arr, int buff, /* add any parameters if you need */) { /* add your code */} int main() { int N = 0, buff = 0; scanf("%d %d", &N, &buff); int *arr = malloc(N * sizeof(int)); for(int i = 0; i < N; i++) { scanf("%d", &arr[i]); } int ans = 1e9; /* add your code */ printf("%d\n", ans); free(arr);}
Input Format
第一行:N (寶箱怪數量)、buff (每打倒一隻寶箱怪增加的攻擊力)
第二行:N個寶箱怪各別的blood (血量)
( 3 <= N <= 12、1 <= buff <= 10、 1 <= blood[i] <= 10^6 )
Output Format
打倒所有寶箱怪的最短秒數。
Sample Input1
12 5 13 5 1 2 4
Sample Output1
1 5
Sample Input2
12 3 13 4 1
Sample Output2
1 4