zoukankan      html  css  js  c++  java
  • luogu -P1095 守望者的逃离

    P1095 守望者的逃离: https://www.luogu.org/problemnew/show/P1095

    题意:

      有一个人要在S长度的直线上跑过去,初始有M的魔法值,用10点魔法值可以在一秒内跑60米,而普通跑一秒17米。保持静止可以恢复4点的魔法值。问能否在T秒前跑完。

    思路:

      分开两次dp,第一次跑出能用加速就用加速的路程。第二次比较dp【i】和dp【i-1】+17的值即可。

    #include <algorithm>
    #include  <iterator>
    #include  <iostream>
    #include   <cstring>
    #include   <iomanip>
    #include   <cstdlib>
    #include    <cstdio>
    #include    <string>
    #include    <vector>
    #include    <bitset>
    #include    <cctype>
    #include     <queue>
    #include     <cmath>
    #include      <list>
    #include       <map>
    #include       <set>
    //#include <unordered_map>
    //#include <unordered_set>
    //#include<ext/pb_ds/assoc_container.hpp>
    //#include<ext/pb_ds/hash_policy.hpp>
    using namespace std;
    //#pragma GCC optimize(3)
    //#pragma comment(linker, "/STACK:102400000,102400000")  //c++
    #define lson (l , mid , rt << 1)
    #define rson (mid + 1 , r , rt << 1 | 1)
    #define debug(x) cerr << #x << " = " << x << "
    ";
    #define pb push_back
    #define pq priority_queue
    
    
    
    typedef long long ll;
    typedef unsigned long long ull;
    
    typedef pair<ll ,ll > pll;
    typedef pair<int ,int > pii;
    typedef pair<int ,pii> p3;
    //priority_queue<int> q;//这是一个大根堆q
    //priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
    //__gnu_pbds::cc_hash_table<int,int>ret[11];    //这是很快的hash_map
    #define fi first
    #define se second
    //#define endl '
    '
    
    #define OKC ios::sync_with_stdio(false);cin.tie(0)
    #define FT(A,B,C) for(int A=B;A <= C;++A)  //用来压行
    #define REP(i , j , k)  for(int i = j ; i <  k ; ++i)
    //priority_queue<int ,vector<int>, greater<int> >que;
    
    const ll mos = 0x7FFFFFFFLL;  //2147483647
    const ll nmos = 0x80000000LL;  //-2147483648
    const int inf = 0x3f3f3f3f;
    const ll inff = 0x3f3f3f3f3f3f3f3fLL; //18
    
    const double PI=acos(-1.0);
    
    template<typename T>
    inline T read(T&x){
        x=0;int f=0;char ch=getchar();
        while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
        while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
        return x=f?-x:x;
    }
    
    /*-----------------------showtime----------------------*/
                const int maxn = 300009;
                int dp[maxn],m,s,t;
    int main(){
                cin>>m>>s>>t;
    
                for(int i=1; i<=t; i++){
                    if(m >= 10){
                        dp[i] = dp[i-1]+60;
                        m -= 10;
                    }
                    else {
                        dp[i] = dp[i-1];
                        m += 4;
                    }
                }
    
                for(int i=1; i<=t; i++){
                    dp[i] = max(dp[i], dp[i-1]+17);
                    if(dp[i]>=s){
                        puts("Yes");
                        printf("%d
    ", i);
                        return 0;
                    }
                }
                puts("No");
                printf("%d
    ", dp[t]);
                return 0;
    }
    P1095
  • 相关阅读:
    解决 EDAS:Upload failed: The right margin is 0.535 in on page 1 问题
    解决 ImportError: No module named _internal
    静态页面如何实现 include 引入公用代码
    一个用 js 实现点阵图的编辑器演示
    从 art-template 模版维护到动态加载的思考
    Atom 备份神器 —— Sync Settings
    clicaptcha中文点击验证码开发经验总结
    通过 imagick 让 PHP 生成 PSD 文件缩略图
    让视频压制更简单
    Medoo个人修改版
  • 原文地址:https://www.cnblogs.com/ckxkexing/p/9734244.html
Copyright © 2011-2022 走看看