守望者的逃离(贪心+动规

 

https://www.luogu.org/problemnew/show/P1095

 

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<string>
 7 #include<cmath>
 8 #include<set>
 9 #include<vector>
10 #include<stack>
11 #include<queue>
12 #include<map>
13 using namespace std;
14 #define ll long long
15 #define mem(a,x) memset(a,x,sizeof(a))
16 #define se second
17 #define fi first
18 const int INF= 0x3f3f3f3f;
19 const int N=3e5+5;
20 
21 int  m,s,t,dp[N];
22 
23 int main()
24 {
25     cin>>m>>s>>t;
26     mem(dp,0);
27     for(int i=1;i<=t;i++)
28     {
29         if(m>=10)
30             dp[i]=dp[i-1]+60,m-=10;
31         else
32             dp[i]=dp[i-1],m+=4;
33     }
34     for(int i=1;i<=t;i++)
35     {
36         if(dp[i]<dp[i-1]+17)
37             dp[i]=dp[i-1]+17;//m+=10;或者m-=4; 按理说要写,但后面没用到m,所以可不写
38         if(dp[i]>=s)
39         {
40             cout<<"Yes"<<endl;
41             cout<<i;
42             return 0;
43         }
44     }
45     cout<<"No"<<endl;
46     cout<<dp[t];
47 }

 

posted @ 2018-07-18 11:06  木流牛马  阅读(101)  评论(0编辑  收藏  举报