Rokua P1095 the Watchman's escape

Source: Internet
Author: User

Title Description

The Demon Hunter, Dean, was so ambitious that he betrayed the night elves and led the Naga tribe, deep in the sea, to rebel. The watchman was killed in a clash with Illidan and was trapped on a deserted Big island. In order to kill the Watchman, Dean began to curse the island, the island will soon sink down. By then, everyone on the island would have been killed. The Watcher's running speed is 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 running, flashing, or resting activity is in seconds (s), and the duration of each activity is an integer second. The unit of distance is in meters (m).

input/output format

Input format:

The input file escape.in only one line, including three non-negative integers m, S, T, separated by spaces.

Output format:

The output file Escape.out 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 the watcher escapes from the Desert Island; the first action "No" (case-sensitive) indicates the maximum distance the watcher can walk.

input/Output sampleInput Sample # #:
"Input Example 1" 39 200 4 "Input Sample 2" 36 255 10
Sample # # of output:
"Output Example 1" No197 "Output Sample 2" Yes6
Description

30% data satisfies: 1 <= T <=, 1 <= S <= 100

50% data satisfies: 1 <= T <=, 1 <= S <= 10000

100% of the data meet: 1 <= T <= 300000, 0 <= M <=, 1 <= S <= 10^8.

1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 structnode{6     intf,g,m;7     //m mofa f zuidajuli G Zhi Shan de juli8}dp[500010];9 intm,s,t;Ten intMain () One { A      -scanf"%d%d%d",&m,&s,&t); -dp[0].m=m;dp[0].f=0;DP [0].g=0; the      for(intI=1; i<=t;i++) -     { -         if(dp[i-1].m>=Ten) -         { +dp[i].m=dp[i-1].m-Ten; -dp[i].g=dp[i-1].g+ -; +         } A         Else{ atdp[i].m=dp[i-1].m+4; -dp[i].g=dp[i-1].g; -         } -Dp[i].f=max (dp[i-1].f+ -, DP[I].G); -     } -      in     if(dp[t].f<s) -     { toprintf"no\n%d", DP[T].F); +         return 0; -     } the      *      while(dp[t].f>=s) t--; $t++;Panax Notoginsengprintf"yes\n%d", T); -     return 0; the}

Idea: it must be possible to jump first, and then divide three variables to record the maximum distance after the time t, and M to represent the energy value after the time t, by mathematical calculation ~,f

G indicates the distance after the time t only by jumping through

Dp[i].f=max (DP[I-1].F+17,DP[I].G);
This is a good question, worth a good look (personal feel more suitable for beginners to consolidate)

Rokua P1095 the Watchman's escape

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.