#include #include using namespace std; #define DEB(x) cout << #x << " = " << x << endl; long long ponds[100001]; long long water[100001]; int main(void) { int n; long long f; while (cin >> n >> f) { for (int i = 0; i < n; i++) { cin >> ponds[i]; water[i] = f; } int rem = n; long long int total = 0; double totalT = 0; bool last = false; double lastTime = 0; while (rem > 0) { for(int i = 0; i < n; i++) { if (ponds[i] > 0) { ponds[i] -= water[i]; if (ponds[i] <= 0) { rem--; if (rem == 0) { totalT = total + (ponds[i] + water[i]) / (double)water[i]; //cout << "totalT " << totalT << " v " << i << endl; } if (i == n - 1) { last = true; lastTime = total + (ponds[i] + water[i]) / (double)water[i]; //cout << "lastTime " << lastTime << " v " << i << endl; } if (i < n - 1) { ponds[i + 1] -= abs(ponds[i]); } } } else { if (i < n -1 ) { water[i + 1] += water[i]; water[i] = 0; } } //cout << "pond " << i << " obsahuje " << ponds[i] << " rychlost " << water[i] << endl; } if (rem > 0) { total += 1; } } cout << lastTime << " " << totalT << endl; } return 0; }