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. Keeper of the Watchmen
He was trapped in a deserted Big Island when he was killed in a clash with Illidan. In order to kill the Watchmen, Dean began to
A desert island to spell, the islands will soon sink. 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 without
Every time you use a flashing spell, you will consume 10 mana points. The Catcher's Mana recovery rate is 4 points/s, only in situ
The rest of the state can be restored.
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 write a program to help the watcher calculate how to escape the desert island in the shortest time, if not escape, then output watch
The furthest distance a person can walk in the remaining time. Note: The watcher's running, flashing, or resting activities are in seconds (s) and each
The duration of the secondary activity is an integer second. The unit of distance is in meters (m).
formatInput Format
In the input file escape.in only one line, including three non-negative integer m,s,t separated by spaces.
output Format
The output file Escape.out includes 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 of "Yes" (case-sensitive) indicates the minimum time for the watcher to flee the desert island;
The first behavior "No" (case-sensitive) indicates the maximum distance the watcher can walk.
Example 1sample input 1[copy]
39 200 4
sample Output 1[copy]
No197
Example 2sample input 2[copy]
36 255 10
sample Output 2[copy]
Yes6
Limit
1s
Tips
30% of the data meet: 1<=t<=10,1<=s<=100
50% of the data meet: 1<=t<=1000,1<=s<=10000
100% of the data meet: 1<=t<=300000,0<=m<=1000,1<=s<=10^8
Source
The 3rd question of NOIP2007 popularization group
Greed: Use the number of spells to update ans, from 0 to T times, pay attention to the judgment of the boundary, to ensure tightness.
1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cmath>5#include <algorithm>6#include <cstring>7 using namespacestd;8 intm,s,t;9 intans=1e9;Ten intMOVE; One intMain () { A -scanf"%d%d%d",&m,&s,&T); - for(intI=0; i<=t;i++) {//Use most I magic the intri+=i; - intMove= -*i; - inttot=Ten*i;//Magic points Required - if(tot>m) {//calculate the time to rest + intdelta=tot-M; - intx1=delta/4; + if(delta%4!=0) Ax1++; attim+=X1; - } - if(tim<=t&&move>=s) {//only magic can reach -ans=min (ans,tim); -Move=Max (move,s); - Continue; in } - Else if(tim>t) {//This sentence is very important to Continue; + } - the intS=s-move;//the distance you need to go * intt1=s/ -; $ if(s% -!=0)Panax Notoginsengt1++; -tim+=T1; the if(tim<=T) { +ans=min (ans,tim); AMove=Max (move,s); the Continue; + } - Else{ $ intt2=t-(tim-t1); $move+=t2* -; -Move=Max (move,move); - } the } - Wuyi if(move<R) { thecout<<"No"<<Endl; -cout<<move<<Endl; Wu } - Else{ Aboutcout<<"Yes"<<Endl; $cout<<ans<<Endl; - } - return 0; -}
The Watchman's escape