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 << "\n";
#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 '\n' #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; //
const ll nmos = 0x80000000LL; //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3fLL; // const double PI=acos(-1.0); template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
} /*-----------------------showtime----------------------*/
const int maxn = ;
int dp[maxn],m,s,t;
int main(){
cin>>m>>s>>t; for(int i=; i<=t; i++){
if(m >= ){
dp[i] = dp[i-]+;
m -= ;
}
else {
dp[i] = dp[i-];
m += ;
}
} for(int i=; i<=t; i++){
dp[i] = max(dp[i], dp[i-]+);
if(dp[i]>=s){
puts("Yes");
printf("%d\n", i);
return ;
}
}
puts("No");
printf("%d\n", dp[t]);
return ;
}

P1095

最新文章

  1. 【TJOI&amp;HEOI2016】【Bzoj4551】树
  2. IntelliJ IDEA 工具常用快捷键
  3. 关于Linux环境变量
  4. pip 添加trusted host 一劳永逸
  5. TCP协议中的三次握手和四次挥手
  6. php获取汉字的拼音 拼音首字母
  7. (转载)Java基础知识总结
  8. 基础套接字的C#网络编程
  9. 《HTML5 CANVAS基础教程》读书笔记
  10. Android学习4&mdash;短信发送器的实现
  11. 2292: 【POJ Challenge 】永远挑战
  12. list.add(),向List集合插入对象报空指针异常
  13. RobotFramework下的http接口自动化post关键字的使用
  14. 芯灵思Sinlinx A33开发板boa与CGI移植
  15. mybatisGenerator代码生成器
  16. caffe boost cuda __float128 undefined
  17. WeakReference与SoftReference
  18. centos7 升级GCC版本到7.3.0
  19. (2.12)Mysql之SQL基础——存储过程条件定义与错误处理
  20. UVALive - 5713 最小生成树

热门文章

  1. 关于引入js文件乱码的问题
  2. Lexical or preprocessor &#39;XXX/XXX.h&#39; issue file not found
  3. jumpserver1.4.1 安装过程
  4. 隐马尔科夫模型HMM介绍
  5. 4. 源码分析---SOFARPC服务端暴露
  6. Spark 系列(四)—— RDD常用算子详解
  7. ThreadLocal线程隔离
  8. 洛谷 P1903 [国家集训队]数颜色
  9. spark源码阅读---Utils.getCallSite
  10. springboot自动配置源码解析