28 lines
1.2 KiB
C++
28 lines
1.2 KiB
C++
#include <bits/stdc++.h>
|
||
using namespace std;
|
||
int m; // 初始魔法值
|
||
int s; // 他所在的初始位置与岛的出口之间的距离
|
||
int t; // 岛沉没的时间
|
||
int d; // 守望者在剩下的时间内能走的最远距离
|
||
|
||
// 贪心思路,可能过 5/11
|
||
int main() {https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/extracted/26c367a3c3cf20e62e1d6c7904f6abf6/9DFECB5E-FBA7-4a26-B6BC-A31BF4B184CA.png
|
||
cin >> m >> s >> t;
|
||
for (int i = 1; i <= t; i++) { // 枚举每一秒
|
||
if (m >= 10) { // 如果剩余魔法值大于10,那么可以进行闪烁
|
||
m -= 10; // 魔法值减10
|
||
d += 60; // 距离增加60
|
||
} else
|
||
m += 4; // 停下来,消耗1秒,魔法值恢复4点
|
||
|
||
if (d >= s) { // 如果走的距离已经大于目标距离,可以走出
|
||
cout << "Yes" << endl; // 说明可以走出去
|
||
cout << i << endl; // 输出需要几秒
|
||
return 0;
|
||
}
|
||
}
|
||
cout << "No" << endl; // 走不出去
|
||
cout << d << endl; // 最远可以走到d这个位置上
|
||
return 0;
|
||
}
|