#include #include /* double gettime(int index, int capacity[], int rate[]) { double this_t = 0, prev_t = 0; if (index == 0) { this_t = (double)capacity[index] / (double)rate[index]; } else { this_t = (double)capacity[index] / (double)rate[index]; prev_t = gettime(index - 1, capacity, rate); if (prev_t < this_t) { this_t = prev_t + ((double)capacity[index] - (double)rate[index] * prev_t) / (double)(rate[index] + rate[index - 1]); rate[index] += rate[index - 1]; } } return this_t; } void setRate(int rate[], int speed, int count) { int i; for (i = 0; i < count; i++) rate[i] = speed; } */ int main() { /* int count, rate; scanf("%d %d\n", &count, &rate); int **array = (int**)malloc(3 * sizeof(int*)); int i = 0; for (i = 0; i < count; i++) { array[i] = (int*)malloc(count * sizeof(int)); } */ /* int count, speed; while (scanf("%d %d\n", &count, &speed) > 0) { int *capacity = (int*)malloc(count * sizeof(int)); int *rate = (int*)malloc(count * sizeof(int)); int i; int capmax = 0, indmax = 0; for (i = 0; i < count; i++) { scanf("%d", capacity + i); if (capacity[i] > capmax) { capmax = capacity[i]; indmax = i; } rate[i] = speed; } double t = gettime(count - 1, capacity, rate); printf("%g ", t); setRate(rate, speed, count); t = gettime(indmax, capacity, rate); printf("%g\n", t); } */ int count, speed; while (scanf("%d %d", &count, &speed) > 0) { int *capacity = (int*)malloc(count * sizeof(int)); int *rate = (int*)malloc(count * sizeof(int)); double *time = (double*)malloc(count * sizeof(double)); int i = 0; for (i = 0; i < count; i++) { scanf("%d", capacity + i); rate[i] = speed; time[i] = 0; } double this_t, prev_t; double max_t = 0; for (i = 0; i < count; i++) { if (i == 0) this_t = (double)capacity[i]/(double)rate[i]; else { this_t = (double)capacity[i]/(double)rate[i]; prev_t = time[i-1]; if (prev_t < this_t) { this_t = prev_t + ((double)capacity[i] - (double)rate[i] * prev_t) / (double)(rate[i] + rate[i-1]); rate[i] += rate[i-1]; } } time[i] = this_t; if (this_t > max_t) max_t = this_t; } printf("%g %g\n", time[count-1], max_t); } return 0; }