要么去体育馆,要么去比赛,要么闲在家里

给出每一天体育馆和比赛的有无情况,要求连续两天不能去同一个地方

问最少闲几天

DP方程很容易看出

  dp(第i天能去的地方) = min(dp(第i-1天的三种情况)) ;

  dp(第i天呆在家里) = min(dp(第i-1天的三种情况))+1;

 #include <cstdio>
#include <iostream>
using namespace std;
#define inf 0x3f3f3f3f
int a[],ans[][],n;
void dfs()
{
ans[][]=ans[][]=ans[][]=;
for(int i=;i<=n;i++)
{
if(a[i]==)
{
ans[i][]=inf;
ans[i][]=inf;
}
else if(a[i]==)
{
ans[i][]=inf;
ans[i][]=min(ans[i-][],ans[i-][]);
}
else if(a[i]==)
{
ans[i][]=inf;
ans[i][]++;
ans[i][]=min(ans[i-][],ans[i-][]);
}
else
{
ans[i][]=min(ans[i-][],ans[i-][]);
ans[i][]=min(ans[i-][],ans[i-][]);
}
ans[i][]=min(ans[i-][],ans[i-][]);
ans[i][]=min(ans[i][],ans[i-][]);
ans[i][]++;
}
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
dfs();
int res=min(ans[n][],ans[n][]);
res=min(res,ans[n][]);
printf("%d\n",res);
}

CodeForces 698A - Vacations (Codeforces Round #363 (Div. 2))的更多相关文章

  1. Codeforces Round 363 Div. 1 (A,B,C,D,E,F)

    Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...

  2. Codeforces Round #363 (Div. 2) C. Vacations —— DP

    题目链接:http://codeforces.com/contest/699/problem/C 题解: 1.可知每天有三个状态:1.contest ,2.gym,3.rest. 2.所以设dp[i] ...

  3. Codeforces Round #363 (Div. 2)->C. Vacations

    C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  4. Codeforces Round #363 (Div. 2) C. Vacations(DP)

    C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. Codeforces Round #363 (Div. 2)

    A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio& ...

  6. Codeforces Round #363 (Div. 1) B. Fix a Tree 树的拆环

    题目链接:http://codeforces.com/problemset/problem/698/B题意:告诉你n个节点当前的父节点,修改最少的点的父节点使之变成一棵有根树.思路:拆环.题解:htt ...

  7. Codeforces Round #363 (Div. 2) D. Fix a Tree —— 并查集

    题目链接:http://codeforces.com/contest/699/problem/D D. Fix a Tree time limit per test 2 seconds memory ...

  8. Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧

    题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...

  9. Codeforces Round #363 Div.2[111110]

    好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...

随机推荐

  1. java 加载图片的几种方式

    项目目录--src--testTable--image--active.gif | |_Task.class 方法1:通过项目目录访问. String a = System.getProperty(& ...

  2. Byte、KB、MB、GB、TB、PB、EB是啥以及它们之间的进率

    它们是存储单位 因为计算机存储单位一般用B,KB.MB.GB.TB.PB.EB.ZB.YB.BB来表示,它们之间的关系是: 位 bit (比特)(Binary Digits):存放一位二进制数,即 0 ...

  3. 1207--ATM自动取款机的实现

    #include <stdio.h> #include <stdlib.h> #include <stdbool.h> //提示用户操作 void alert(ch ...

  4. //NSUserDeafult 图片的保存与读取

    //NSUserDeafult保存图片数据到本地 -(void)saveImage:(UIImage *)image{ NSData* data=[NSKeyedArchiver archivedDa ...

  5. 通过XSLT转换XML

    Hello,every body.又与大家见面了,哈哈.今天我与大家分享一下XSLT,XSL,XML,XPath.因为项目中有些功能用到了XSLT.XML等技术.所以今天好好研究了一下这几个方面的技术 ...

  6. virtual box 改变已经创建的虚拟系统分配的硬盘

    启动cmd,进入virtualbox安装的目录 :cd E:\Program Files\Oracle\VirtualBox 然后输入VBoxManage.exe list hdds ,可以看到 D: ...

  7. jquery的使用 超级快速入门 熟练使用

    如何使用jquery,首先需要引入jquery的js库文件,可以是免费的cdn资源,也可以是本地下载的资源 使用方法:$(function(){                  这里面写你要执行的代 ...

  8. PHP ReflectionClass

    <?php /** * @desc test reflectionclass * @author songweiqing * @create_time 2015-01-7 * */ class ...

  9. python中print后面加逗号

    python中print输出一行,如果想多次输出的内容不换行,可以在print后面加逗号 例如 每个输出一行 phrase = "abcdefg" # Add your for l ...

  10. 异常处理与调试2 - 零基础入门学习Delphi51

    异常处理与调试2 让编程改变世界 Change the world by program Delphi 异常类 利用异常机制,就是允许写代码时可以假设:如果用户可以得到子程序调用或计算的结果,这些结果 ...