题目链接: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)的更多相关文章

  1. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  2. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  3. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  4. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  5. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  6. [BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆)

    [BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆) 题面 一棵二叉树的所有点的点权都是给定的集合中的一个数. 让你求出1到m中所有权 ...

  7. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  8. CodeForces #363 div2 Vacations DP

    题目链接:C. Vacations 题意:现在有n天的假期,对于第i天有四种情况: 0  gym没开,contest没开 1  gym没开,contest开了 2 gym开了,contest没开 3 ...

  9. codeforces round367 div2.C (DP)

    题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...

随机推荐

  1. php 正则匹配中文

    在javascript中,要判断字符串是中文是很简单的.比如:var str = "php编程";if (/^[\u4e00-\u9fa5]+$/.test(str)) {aler ...

  2. poj-------(2240)Arbitrage(最短路)

    Arbitrage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15640   Accepted: 6563 Descri ...

  3. eclipse hibernate 插件测试1

    今天先测试了hibernate tools 安装 在eclipse marketplace里面搜索 hibernate tools 就能找到 网上很多文章所说的使用 install new softw ...

  4. placehold.it-在线图片生成器(转载)

    做网站的时候 如果 有的产品等客户没有上传图片,可以用这个网站生成的图片 并配以文字进行图片的占位 以免造成页面的空挡或者页面错位等 原文地址:http://www.cnblogs.com/xumen ...

  5. iOS开发零碎笔记

    Mac常用操作 全屏截图:同时按住键盘左下方的command和shift   ,然后点击键盘上方的数字键3,便可对整个屏幕截图,截图会自动保存在桌面:任意部分截图:同时按住键盘左下方的ommand和s ...

  6. NoSQL你知多少?

    1.NoSQL是什么? NoSQL 是 Not Only SQL 的缩写,意即"不仅仅是SQL"的意思,泛指非关系型的数据库.强调Key-Value Stores和文档数据库的优点 ...

  7. BZOJ2621 [Usaco2012 Mar]Cows in a Skyscraper

    首先比较容易想到是状态压缩DP 令$f[S]$表示选取了集合$S$以后,已经送了最少次数$cnt$且当前电梯剩下的体积$rest$最大(即$f[S]$是一个二元组$(cnt, rest)$) 于是$f ...

  8. function gzdecode

    function gzdecode($data) { return gzinflate(substr($data,10,-8)); } 因为项目要下载一个gzip压缩的网页,所以需要解压,手册上有一个 ...

  9. uiwebview 清缓存。,mark

    //清除cookies NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCook ...

  10. Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'

    给UITableViewController 展示数据时候 删除系统自带viewController 然后拖过来一个UITableViewController 指定class后没有指定main入口 报 ...