CodeForces 698A - Vacations (Codeforces Round #363 (Div. 2))
要么去体育馆,要么去比赛,要么闲在家里
给出每一天体育馆和比赛的有无情况,要求连续两天不能去同一个地方
问最少闲几天
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))的更多相关文章
- Codeforces Round 363 Div. 1 (A,B,C,D,E,F)
Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...
- 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] ...
- 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 ...
- 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 ...
- Codeforces Round #363 (Div. 2)
A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio& ...
- Codeforces Round #363 (Div. 1) B. Fix a Tree 树的拆环
题目链接:http://codeforces.com/problemset/problem/698/B题意:告诉你n个节点当前的父节点,修改最少的点的父节点使之变成一棵有根树.思路:拆环.题解:htt ...
- 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 ...
- Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧
题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...
- Codeforces Round #363 Div.2[111110]
好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...
随机推荐
- Lambda表达式的面纱(一)
在.NET3.0版本中微软推出了Lambda表达式.这使代码的表述可以更加优雅.但是对于新事物大多会本能的排斥,虽然3.0版本已经推出了好久了,但是我向周围的人了解了一下,用Lambda的人不是很多, ...
- fddd
<script language="JavaScript" type="text/javascript"> function exportChart ...
- toJOSN()方法
toJSON方法可以作为函数过滤器的补充.序列化的顺序如下: (1)如果存在toJSON方法而且能够通过它取得有效值,则调用该方法. (2)如果提供了第二个参数,应用该函数过滤器.传入过滤器的值是步骤 ...
- javascript事件捕获与冒泡
对“捕获”和“冒泡”这两个概念,我想我们对冒泡更熟悉一些,因为在我们使用的所有浏览器中,都支持事件冒泡,即事件由子元素向祖先元素传播的,就 像气泡从水底向水面上浮一样.而在像firefox,chrom ...
- IE6 双倍距BUG
IE6双倍距BUG的形成: 1.快元素 2.元素浮动 3.margin左右 解决方案:_display:inline;
- Bootstrap 静态分页 和 jquery_pagination插件 动态分页
第一种Bootstrap 实例 - 默认的分页 <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - ...
- python运维开发(十八)----Django(二)
内容目录 路由系统 模版 Ajax model数据库操作,ORM 路由系统 django中的路由系统和其他语言的框架有所不同,在django中每一个请求的url都要有一条路由映射,这样才能将请求交给对 ...
- 无聊写了一个最简单的MVC4+Highcharts连数据库例子
乱搞了个数据库 后面发现没定INT类型 直接将ID当数据显示了 效果图: 前端 @{ Layout = null; } <!DOCTYPE html> <html> <h ...
- Mysql基础教程——mysql之一
教程列表:http://www.dxzy163.com/view/index7627.html 41 存储过程 40 全文索引与停止词 39 索引的管 38 索引概念 37 数据库备份与恢复 36 事 ...
- SQL Server 2008空间数据应用系列七:基于Bing Maps(Silverlight) 的空间数据展现
原文:SQL Server 2008空间数据应用系列七:基于Bing Maps(Silverlight) 的空间数据展现 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft ...