题目
输入#1
39 200 4
输出#1
No
197
输入#2
36 255 10
输出#2
Yes
6
思路
每秒的选择只有走,休息,闪烁三种,但是休息和闪烁和mp有关,可以先计算休息和闪烁再加上走的情况。
m>=10 :dp[i]=dp[i-1]+60//闪烁
m<10 :dp[i]=dp[i-1];//休息
加上走的情况
dp[i]=max(dp[i-1]+17,dp[i]);
#include <iostream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <queue>
#include <vector>
#include <cstdio>
#include <queue>
#include <sstream>
#include <string>
#include <algorithm>
#include <map>
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define reps(i, a, b) for (int i = a; i >= b; i--)
#define mk make_pair
using namespace std;
const int N = 1e5 + 7;
const int M = 3e6 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
typedef long long ll;
int dp[M];
int main()
{
int m,s,t;
scanf("%d%d%d",&m,&s,&t);
rep(i,1,t){
if(m>=10){
m-=10;
dp[i]=dp[i-1]+60;
} else{
m+=4;
dp[i]=dp[i-1];
}
}
rep(i,1,t){
dp[i]=max(dp[i-1]+17,dp[i]);
if(dp[i]>=s){
puts("Yes");
printf("%d\n",i);
return 0;
}
}
if(dp[t]<s){
puts("No");
printf("%d\n",dp[t]);
}
return 0;
}