Question Description |
The Demon Hunter was particularly ambitious. He betrayed the night elves, and the rate of the deep seabed was attempted mutiny: The watchman was killed in a clash with Illidan. Trapped on a deserted Big island. In order to kill the Watchman, Dean began to curse the island, the island will soon sink, until then, all the knives will be killed: The watchman's running speed, for 17m/s, at such a speed is unable to escape the desert island. Fortunately, the watcher has a flashing spell that can move 60m within 1s, but each use of a flashing spell consumes a mana value of 10 points. The Catcher's Mana recovery rate is 4 points/s, which can only be restored when in-situ resting state. Now known as the Watcher's magical initial value m, the distance between his initial position and the island's exit S, the island sank time t. Your task is to write a program to help the watcher calculate how to escape from the desert island in the shortest time, if not escape, then the output watcher in the remaining time to walk the farthest distance. Note: The watcher's running, flashing, or resting activities are in seconds (s). and the duration of each activity is an integer second. The unit of distance is in meters (m). |
Input |
Only one row, including three non-negative integer m,s,t separated by a space. |
Output |
Contains two lines: The 1th behavior string "Yes" or "No" (case-sensitive), that is, whether the watcher can escape from the desert island. Line 2nd contains an integer, the first Behavior "Yes" (case-sensitive) indicates the shortest time to flee the desert island The first behavior "No" (case-sensitive) indicates the maximum distance the watcher can walk. |
Input example |
39 200 4 |
Output example |
No 197
|
Other Notes |
Limitations: 30% Data: 1 <= t<=, 1 <=s<= 100, 50% data satisfied: 1 <= T <=, 1 <= S <= 10000;100% data: 1 < = T <= 300000, 0 <= m<=1000 1 <=s <= 10^8
|
|
Dynamic planning is similar to knapsack problems.
1#include <iostream>2 3 using namespacestd;4 inta[300000];5 intMain ()6 {7 intI,m,s,t;//The watcher's magical initial value m, the distance between his initial position and the island's exit S, the time the island sank T8scanf"%d%d%d",&m,&s,&T);9 for(i=1; i<=t;i++)Ten { One if(m>=Ten) {a[i]=a[i-1]+ -; m-=Ten;}//If you can use magic A Else{a[i]=a[i-1]; m+=4;}//Otherwise the Mana value is +4 . - } - for(i=1; i<=t;i++) the { - if(a[i]<a[i-1]+ -) {a[i]=a[i-1]+ -;}//Walk - if(a[i]>=s) {cout<<"Yes"<<endl<<i;return 0;} - } +cout<<"No"<<endl<<A[t]; - //System ("pause"); + return 0; A}
NOIP200703 The watchman's escape
NOIP200703 Watcher's escape