codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C
dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2。
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int dp[105][3];
int main()
{
int n;
scanf("%d",&n);
memset(dp,INF,sizeof(dp));
dp[0][0] = dp[0][1] = dp[0][2] = 0;
for(int i = 1 ;i <= n ;i++)
{
int x;
scanf("%d",&x);
dp[i][0] = min(dp[i-1][0],min(dp[i-1][1],dp[i-1][2]))+1;
if(x == 1||x == 3)
dp[i][1] = min(dp[i-1][0],dp[i-1][2]);
if(x == 2||x == 3)
dp[i][2] = min(dp[i-1][0],dp[i-1][1]);
}
printf("%d\n",min(dp[n][0],min(dp[n][1],dp[n][2])));
return 0;
}
codeforces #round363 div2.C-Vacations (DP)的更多相关文章
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- [BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆)
[BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆) 题面 一棵二叉树的所有点的点权都是给定的集合中的一个数. 让你求出1到m中所有权 ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- CodeForces #363 div2 Vacations DP
题目链接:C. Vacations 题意:现在有n天的假期,对于第i天有四种情况: 0 gym没开,contest没开 1 gym没开,contest开了 2 gym开了,contest没开 3 ...
- codeforces round367 div2.C (DP)
题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...
随机推荐
- ajax异步加载小例子....(通俗易懂)
web.html(用户端): <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- EF 7 Code First
加载方式三种 1. Eager Loading 2. Lazy Loading 3.Explicit Loading 使用EF在与关系型数据库的交互中不可避免地需要加载数据,如何加载数据变得至关重要. ...
- shell学习记录003-cat命令
cat 命令一般用于文件的查看 cat -s file #可以去除文件中多余的上下空行 cat -T file #Python编程中会用到的制表符会在该命令中体现出来 cat -n file ...
- Linux 中 10 个有用的命令行补全例子
在 Linux 系统中,当你输入一个命令,再按两次 TAB 键,就会列出所有以你输入字符开头的可用命令.这并不新鲜,可能你已经知道了.这个功能被称作命令行补全bash completion.默认情况下 ...
- 操作系统cmd算法
实验一 命令解释程序的编写(两周内) 一.目的和要求 1. 实验目的 (1)掌握命令解释程序的原理: (2)*掌握简单的DOS调用方法: (3)掌握C语言编程初步. 2.实验要求 编写类似于DOS, ...
- 铁人系列(2)LA2218
思路:对于每个人 都会有n-1个半片面 加上x>0,y>0,1-x-y>0(这里的1抽象为总长) 代码是粘贴的 原来写的不见了 orz............ // LA22 ...
- PHP安装pthreads多线程扩展教程[windows篇]
from:http://blog.csdn.net/aoyoo111/article/details/19020161 一.判断PHP是ts还是nts版 通过phpinfo(); 查看其中的 Thre ...
- HDU 2181 哈密顿绕行世界问题 dfs 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=2181 只有20个城市,而且每个点的度数恰好是3,也就意味着,对于即将进入环中的点,入度1,出度2,下一个点只有两 ...
- POJ 2992 求组合数的因子个数
求C(n,k)的因子个数 C(n,k) = (n*(n-1)*...*(n-k+1))/(1*2*...*k) = p1^k1 * p2^k2 * ... * pt^kt 这里只要计算出分子中素数因子 ...
- CSS盒子模型和IE浏览器
CSS盒模型图解 下面是一幅关于应用了CSS的元素是如何显示它的尺寸的图示. 在本篇文章中,所有的浏览器在计算盒模型总宽度时处理margin属性的方式都是一致的,所以我们将更多的精力放在padding ...