P1095 [NOIP 2007 Junior] The Warden's Escape

Background

NOIP2007 普及组 T3

Description

The ambitious demon hunter Youdian (pinyin) betrayed the Night Elves and led the Naga hidden in the depths of the sea in an attempted rebellion. In a confrontation with Youdian, the Warden fell into an ambush and was trapped on a desolate island. To kill the Warden, Youdian cast a spell on the island, which would soon sink. By then, everyone on the island would perish. The Warden’s running speed is $17\text{m/s}$, which is not enough to escape the island. Fortunately, the Warden has the “Blink” spell, which moves $60\text{m}$ in $1\text{s}$, but each use consumes $10$ mana points. The Warden’s mana regenerates at $4$ points per second, and only while standing still to rest. You are given the Warden’s initial mana $M$, the distance $S$ from the starting position to the island’s exit, and the time $T$ before the island sinks. Your task is to write a program to help the Warden compute how to escape the island in the shortest time. If escape is impossible, output the farthest distance the Warden can travel within the remaining time. Note: Running, blinking, and resting are measured in seconds, and each action lasts an integer number of seconds. Distances are measured in meters.

Input Format

A single line containing three non-negative integers, denoting $M$, $S$, $T$.

Output Format

Output two lines. The first line contains a string $\texttt{Yes}$ or $\texttt{No}$, indicating whether the Warden can escape the island. The second line contains an integer. If the first line is $\texttt{Yes}$, it represents the minimum time for the Warden to escape. If the first line is $\texttt{No}$, it represents the farthest distance the Warden can travel.

Explanation/Hint

For $30\%$ of the testdata, $1 \le T \le 10$, $1 \le S \le 100$. For $50\%$ of the testdata, $1 \le T \le 10^3$, $1 \le S \le 10^4$. For $100\%$ of the testdata, $1 \le T \le 3\times 10^5$, $0 \le M \le 10^3$, $1 \le S \le 10^8$. Translated by ChatGPT 5