private void Go() { int T = m_io.ReadInt(); for (int t = 0; t < T; t++) { double C_FarmCost = m_io.ReadDouble(); double F_FarmBonus = m_io.ReadDouble(); double X_Goal = m_io.ReadDouble(); double currentRate = 2.0; //c/s double currentTime = 0.0; //s double currentCookies = 0.0; //c for (; ;) { double timeToWinWithCurrentFarms = (X_Goal - currentCookies) / currentRate; double timeUntilAffordNextFarm = (C_FarmCost - currentCookies) / currentRate; double timeToWinWithAnotherFarm = timeUntilAffordNextFarm + X_Goal / (currentRate + F_FarmBonus); if (timeToWinWithCurrentFarms < timeToWinWithAnotherFarm) { m_io.WriteCase(currentTime + timeToWinWithCurrentFarms); break; } else { currentTime += timeUntilAffordNextFarm; currentCookies = 0.0; currentRate += F_FarmBonus; } } } }
private void Go() { int T = m_io.ReadInt(); for (int t = 0; t < T; t++) { int N_Blocks = m_io.ReadInt(); double[] Naomi = new double[N_Blocks]; double[] Ken = new double[N_Blocks]; for (int i = 0; i < N_Blocks; i++) { Naomi[i] = m_io.ReadDouble(); } for (int i = 0; i < N_Blocks; i++) { Ken[i] = m_io.ReadDouble(); } Array.Sort(Naomi); Array.Sort(Ken); //deceptive: pop lowest until int kSmallest = 0; int nSmallest = 0; int kLargest = N_Blocks - 1; int nLargest = N_Blocks - 1; int normalScore = 0; //Normal for (int i = 0; i < N_Blocks; i++) { if (Naomi[nLargest] > Ken[kLargest]) { nLargest--; kSmallest++; normalScore++; } else { nLargest--; kLargest--; } } kSmallest = 0; nSmallest = 0; kLargest = N_Blocks - 1; nLargest = N_Blocks - 1; int deceptiveScore = 0; //deceptive for (int i = 0; i < N_Blocks; i++) { if (Naomi[nSmallest] < Ken[kSmallest]) { kLargest--; nSmallest++; } else { nSmallest++; kSmallest++; deceptiveScore++; } } m_io.WriteCase(deceptiveScore + " " + normalScore); } }