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个单位 ...
随机推荐
- UIAlertView与UIActionSheet
1.UIAlertView(警告框) 1.1 创建警告框,设置样式 - (IBAction)alertView:(UIButton *)sender {//创建button按钮 //创建警告框的实例 ...
- iOS 之URL schemes
添加 URL schemes 步骤: 1.打开info.plist文件. 2.点击 “+ ”号添加,或者在列表上点击鼠标右键,选择 Add Row. 3.选择 URL types. 4.点击三角号展 ...
- TexturePacker文件的反向解析-TextureUnpacker
最近在使用cocos2d-x做开发,其中会用到TexturePacker工具打包纹理文件,但是有时候想从打包好的.plist和.png大图文件反向生成原始的小图文件,TexturePacker好像没有 ...
- C++程序设计实践指导1.10二维数组元素换位改写要求实现
改写要求1:改写为以单链表和双向链表存储二维数组 改写要求2:添加函数SingleLinkProcess()实现互换单链表中最大结点和头结点位置,最小结点和尾结点位置 改写要求3:添加函数Double ...
- Lucene学习总结之五:Lucene段合并(merge)过程分析
一.段合并过程总论 IndexWriter中与段合并有关的成员变量有: HashSet<SegmentInfo> mergingSegments = new HashSet<Segm ...
- Android 周报
1. https://androidsweets.ongoodbits.com/ 2. https://www.androiddevdigest.com/ 3.http://us12.campaign ...
- Oracle中index by binary_integer的作用
如语句:type numbers is table of number index by binary_integer;其作用是,加了”index by binary_integer ”后,num ...
- 【Ecstore】为自建模块添加自定义主题模板
做好ECSOTRE模块后,需在主题中添加模板,而添加模板页面时只有产品分类页.产品详细页.首页等内置模块的模板类型. 下面介绍如何添加一个自定义的模板类型“buildings”. 一.修改(建议复制到 ...
- 利用matlab实现以下功能:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。
程序思路: 对n进行分解质因数,应先找到一个最小的质数k,从2开始,然后按下述步骤完成: (1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可. (2)如果n不等于k,则应打印出k的 ...
- SQL Server 索引的图形界面操作 <第十二篇>
一.索引的图形界面操作 SQL Server非常强大的就是图形界面操作.关于索引方面也一样那么强大,很多操作比如说重建索引啊,查看各种统计信息啊,都能够通过图形界面快速查看和操作,下面来看看SQL S ...