http://www.gdutcode.sinaapp.com/problem.php?cid=1049&pid=3

dp[i][state]表示处理了前i个,然后当前状态是state的时候的最小休息天数。

比如用1代表休息,2是训练,3是运动。

如果当前这天允许的状态只是训练。

那么dp[i][3] = inf(表示不可能)

休息是无论何时都可能的了。从dp[i - 1][1--3]个状态转过来, + 1即可

那个求导是-24

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string> const int maxn = + ;
int dp[maxn][];
void work() {
int n;
scanf("%d", &n);
memset(dp, , sizeof dp);
for (int i = ; i <= n; ++i) {
int x;
scanf("%d", &x);
if (x == ) {
dp[i][] = min(dp[i - ][], min(dp[i - ][], dp[i - ][])) + ;
dp[i][] = dp[i][] = inf;
} else if (x == ) {
dp[i][] = dp[i - ][];
dp[i][] = min(dp[i][], dp[i - ][]);
dp[i][] = min(dp[i - ][], min(dp[i - ][], dp[i - ][])) + ;
dp[i][] = inf;
} else if (x == ) {
dp[i][] = inf;
dp[i][] = min(dp[i - ][], dp[i - ][]);
dp[i][] = min(dp[i - ][], min(dp[i - ][], dp[i - ][])) + ;
} else if (x == ) {
dp[i][] = min(dp[i - ][], min(dp[i - ][], dp[i - ][])) + ;
dp[i][] = min(dp[i - ][], dp[i - ][]);
dp[i][] = min(dp[i - ][], dp[i - ][]);
}
}
int ans = inf;
for (int i = ; i <= ; ++i) {
ans = min(ans, dp[n][i]);
}
cout << ans * (-) << endl;
}
int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
int t;
scanf("%d", &t);
while (t--) work();
return ;
}

最新文章

  1. 在Nodejs中如何调用C#的代码
  2. appCan uexLocation 定位功能
  3. python 注意事项
  4. 根据指定Word模板生成Word文件
  5. log4net使用简明教程
  6. ArcGIS Desktop 与 Excel(转)
  7. struts2 修改action的后缀
  8. BZOJ_1003_[ZJOI2006]_物流运输_(动态规划+最短路)
  9. ng-html 报 不安全 警告解决办法
  10. 树莓派学习路程No.1 树莓派系统安装与登录 更换软件源 配置wifi
  11. CentOS 6.4源码编译安装httpd并启动测试
  12. 转delphi中nil的用法
  13. wxPython中按钮、文本控件的简单运用
  14. 跟我一起读postgresql源码(十)——Executor(查询执行模块之——Scan节点(下))
  15. Git更新代码到本地
  16. codecs and formats of digital media
  17. C++类中的静态成员变量和静态成员函数的作用
  18. Tomcat性能优化(三) Executor配置
  19. codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)
  20. Spring Security中异常上抛机制及对于转型处理的一些感悟

热门文章

  1. jvm 命令
  2. sbt is a build tool for Scala, Java, and more
  3. Windows下VMware虚拟机使用Centos,Docker方式安装openstf的小坑
  4. I2S总线协议理解
  5. dedecms时间格式调用标签汇总
  6. MYSQL进阶学习笔记六:MySQL视图的创建,理解及管理!(视频序号:进阶_14,15)
  7. codeforces 448B. Suffix Structures 解题报告
  8. 一步一步学Silverlight 2系列(17):数据与通信之ADO.NET Data Services
  9. SideBar---fixed定位
  10. jquery实现无限滚动瀑布流实现原理