【Luogu1095】守望者的逃离

problem

solution

codes

//f[i]:第i秒最远可以走多远
#include
using namespace std;
const int maxn = 300010;
int m, s, t, f[maxn];
int main(){
    cin>>m>>s>>t;
    for(int i = 1; i <= t; i++){ //dp
        if(m >= 10){ f[i]=f[i-1]+60; m-=10; }else {f[i]=f[i-1]; m+=4;}
    }
    for(int i = 1; i <= t; i++){//贪心
        if(f[i]1]+17)f[i]=f[i-1]+17;
        if(f[i]>=s){cout<<"Yes\n"<"\n"; return 0;}
    }
    cout<<"No\n"<"\n";
    return 0;
}

你可能感兴趣的:(算法)