求助
查看原帖
求助
291489
xiexie楼主2021/2/7 20:52
#include<bits/stdc++.h>
using namespace std;
int ans = 0 ;
int f[30010][14];
int t , s , m;
void dfs(int nowtime ,int way ,int value)
{
	if(nowtime > t)
		return ;
	if(way >= s)
	{
		return; 
	}
	if(way <= f[nowtime][value])
		return;
	f[nowtime][value] = way;
	if(value >= 10)
	{
		dfs(nowtime + 1, way + 60 , value - 10);
	}else
	{
		dfs(nowtime + 1 ,way + 17 , value);
		dfs(nowtime + 1 , way , value + 4);
	}
}
int main()
{	
	memset(f , -1 , sizeof(f));
	cin >> m >> s >> t;
	
	int starttime = 0 , startway = 0;
	while(m >= 10 && starttime < t && startway < s)
	{
		m -= 10;
		startway += 60;
		starttime ++;
	}
	
	if(startway >= s)
	{
		cout << "Yes"<< endl<< starttime;
		return 0;
	}
	if(starttime >= t)
	{
		cout << "No"<< endl<< starttime;
		return 0;
	}
	dfs(starttime , startway , m);
	for(int i = 1 ;i <= t;i++)
	{
		for(int j = 0 ;j <= 13;j++)
		{
			ans = max(ans , f[i][j]);
			if(f[i][j] >= s)
			{
				cout << "Yes" << endl << i;
				return 0;
			}
		}
	}
	cout << "No" << endl << ans;
	return 0;
}

2021/2/7 20:52
加载中...