【Luogu1095】守望者的逃离

problem

solution

codes

//f[i]:第i秒最远可以走多远
#include<iostream>
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]<f[i-1]+17)f[i]=f[i-1]+17;
        if(f[i]>=s){cout<<"Yes\n"<<i<<"\n"; return 0;}
    }
    cout<<"No\n"<<f[t]<<"\n";
    return 0;
}
posted @ 2018-06-04 21:36  gwj1139177410  阅读(149)  评论(0编辑  收藏  举报
选择