#include <stdio.h>
int main()
{
int M, S, T;
int moved = 0, time = 0; // moved 表示王子移动的距离, time 表示王子花掉的时间
scanf("%d%d%d", &M, &S, &T);
if (S == 0)
{
puts("Yes 0");
return 0;
}
else if (T == 0)
{
puts("No 0");
return 0;
}
while ( moved < S && time < T ) {
if ( M >= 10)
{ // 情形1:魔法值充分(大于等于10),优先闪烁
moved += 60;
time++;
M -= 10;
}
else if ( M >= 6 && T - time >= 2 && S - moved > 34 )
{ // 情形2
moved += 60;
time += 2;
M -= 6; // 这里不能 M -= 10,因为休息1秒后增了4点魔法值,下同
}
else if ( M >= 2 && T - time >= 3 && S - moved > 51 )
{ // 情形3
moved += 60;
time += 3;
M -= 2;
}
else if ( T - time >= 7 && S - moved >= 120 )
{ // 情形4
moved += 120;
time += 7;
}
else
{ // 情形5
int n1 = T - time;
int n2 = (S - moved + 16 ) / 17; // 考虑剩余距离不足17m的情况,所以要加上16,不然的话就不能得到1s
int nn = n1 < n2 ? n1 : n2;
moved += nn * 17;
time += nn;
}
}
if ( moved >= S)
{
printf("Yes %d\n",time);
}
else {
printf("No %d\n",moved);
}
return 0;
}
转载于:https://blog.51cto.com/mrcage/1564468