谁来救救孩子啊......
查看原帖
谁来救救孩子啊......
807181
PoorGhost楼主2023/11/2 17:47

f[i][0]表示第i秒选择跑步

f[i][1]表示第i秒选择使用魔法

f[i][2]表示第i秒选择用来恢复魔法

f[i][j].first表示第i秒的第j种状态已经走了多少路

f[i][j].second表示第i秒的第j种状态现有的魔法(能量值)有多少
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pii;
const int N = 3e5+5;
int m,s,t;
pii f[N][3];
bool cmp(const pii &a,const pii &b)
{
    return a.first > b.first;
}
void solve()
{
    memset(f,0,sizeof f);
    cin>>m>>s>>t;
    for(int i=0;i<3;i++)
    {
        f[1][i] = {0,m};
    }
    for(int i=1;i<=t;i++)
    {
        f[i][0] = max({f[i-1][0],f[i-1][1],f[i-1][2]},cmp);
        f[i][0].first += 17;
        f[i][2] = max({f[i-1][0],f[i-1][1],f[i-1][2]},cmp);
        f[i][2].second += 4;
        if(f[i-1][0].second >= 10)
        {
            if(f[i-1][0].first + 60 > f[i][1].first)
            {
                f[i][1].first = f[i-1][0].first + 60;
                f[i][1].second = f[i-1][0].second - 10;
            }
        }
        if(f[i-1][1].second >= 10)
        {
            if(f[i-1][1].first + 60 > f[i][1].first)
            {
                f[i][1].first = f[i-1][1].first + 60;
                f[i][1].second = f[i-1][1].second - 10;
            }
        }
        if(f[i-1][2].second >= 10)
        {
            if(f[i-1][2].first + 60 > f[i][1].first)
            {
                f[i][1].first = f[i-1][2].first + 60;
                f[i][1].second = f[i-1][2].second - 10;
            }
        }
        if(f[i][0].first >= s)
        {
            cout<<"Yes"<<endl;
            cout<<i<<endl;
            return;
        }
        if(f[i][1].first >= s)
        {
            cout<<"Yes"<<endl;
            cout<<i<<endl;
            return;
        }
        if(f[i][2].first >= s)
        {
            cout<<"Yes"<<endl;
            cout<<i<<endl;
            return;
        }
    }
    int ans = max({f[t][0].first,f[t][1].first,f[t][2].first});
    cout<<"No"<<endl;
    cout<<ans<<endl;
}
signed main()
{
    int T = 1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
2023/11/2 17:47
加载中...