| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 82970 | sh25_shenpy | 守望者的逃离 | C++ | 解答错误 | 1 MS | 252 KB | 2910 | 2026-01-18 17:20:11 |
#include <iostream> #include <algorithm> using namespace std; int main() { int M, S, T; cin >> M >> S >> T; int current_magic = M; // 当前魔法值 int distance = 0; // 已移动距离 int time_used = 0; // 已用时间 bool escaped = false; // 是否逃出 while (time_used < T) { // 优先闪烁:如果魔法足够,直接闪烁 if (current_magic >= 10) { distance += 60; current_magic -= 10; time_used++; } // 魔法不足,休息回蓝(前提是回蓝后能更快逃出,否则直接跑步) else { // 计算需要休息的时间:至少回蓝到10点,且休息+闪烁的总效率 > 直接跑步 int need_rest = min(T - time_used, (10 - current_magic + 3) / 4); // 向上取整:(a+b-1)/b if (need_rest > 0 && time_used + need_rest < T) { // 休息need_rest秒,回蓝 current_magic += need_rest * 4; time_used += need_rest; continue; } // 无法通过休息回蓝(时间不够),直接跑步 distance += 17; time_used++; } // 检查是否逃出 if (distance >= S) { escaped = true; break; } } // 处理最后一秒可能的跑步(时间用完前的剩余时间) if (!escaped && time_used < T) { int remaining_time = T - time_used; distance += remaining_time * 17; // 再次检查是否逃出(极端情况:跑步后刚好逃出) if (distance >= S) { escaped = true; time_used = T; } } // 输出结果 if (escaped) { cout << "Yes" << endl; // 修正:如果是跑步逃出,最短时间是 原时间 + 刚好逃出的步数(而非直接T) // 重新计算精确的最短时间 int exact_time = 0; int d = 0, m = M; for (exact_time = 1; exact_time <= T; exact_time++) { if (m >= 10) { d += 60; m -= 10; } else { m += 4; if (m > 1000) m = 1000; // 魔法值不超过初始上限(题目未提,合理假设) } if (d >= S) break; // 如果这一秒没闪烁,也可以选择跑步(可能更快逃出) int run_d = (exact_time) * 17; if (run_d >= S) { exact_time = (S + 16) / 17; // 向上取整:跑步需要的时间 break; } } cout << exact_time-1 << endl; } else { cout << "No" << endl; cout << min(distance, S) << endl; // 距离不超过S(逃出即停止) } return 0; }