麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發(fā)設計 > 正文

Codeforces 699 C. Vacations ( 貪心

2019-11-14 12:56:45
字體:
來源:轉載
供稿:網(wǎng)友
C. Vacationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Vasya has n days of vacations! So he decided to imPRove his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:

on this day the gym is closed and the contest is not carried out; on this day the gym is closed and the contest is carried out; on this day the gym is open and the contest is not carried out; on this day the gym is open and the contest is carried out.

On each of days Vasya can either have a rest or write the contest (if it is carried out on this day), or do sport (if the gym is open on this day).

Find the minimum number of days on which Vasya will have a rest (it means, he will not do sport and write the contest at the same time). The only limitation that Vasya has — he does not want to do the same activity on two consecutive days: it means, he will not do sport on two consecutive days, and write the contest on two consecutive days.

Input

The first line contains a positive integer n (1?≤?n?≤?100) — the number of days of Vasya’s vacations.

The second line contains the sequence of integers a1,?a2,?…,?an (0?≤?ai?≤?3) separated by space, where:

ai equals 0, if on the i-th day of vacations the gym is closed and the contest is not carried out; ai equals 1, if on the i-th day of vacations the gym is closed, but the contest is carried out; ai equals 2, if on the i-th day of vacations the gym is open and the contest is not carried out; ai equals 3, if on the i-th day of vacations the gym is open and the contest is carried out.Output

Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses:

to do sport on any two consecutive days, to write the contest on any two consecutive days. ExamplesInput
41 3 2 0Output
2Input
71 3 3 2 1 2 3Output
0Input
22 2Output
1Note

In the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.

In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.

In the third test Vasya can do sport either on a day number 1 or number 2. He can not do sport in two days, because it will be contrary to the his limitation. Thus, he will have a rest for only one day.

題意:: 一個人在一天內(nèi)有四種選擇

休息,運動||休息,工作||休息,運動||工作 工作或者運動不能連續(xù)超過兩天,求最短的休息時間 重點就是不要連續(xù)超過兩天就可以 數(shù)據(jù)比較小,暴力就可以AC了

#include<stdio.h>int arr[105];int main(){ int n; while(~scanf("%d",&n)) { for(int i = 0;i < n; i++) scanf("%d",&arr[i]); int k = 0, flag = 0; for(int i = 0;i < n; i++) { if(arr[i] == 0) { k++; flag = 0; } else if(arr[i]==1 || arr[i]==2) { if(flag == arr[i]) { k++; flag = 0; } else flag =arr[i]; } else { if(flag == 1) { flag = 2; } else if(flag == 2) { flag = 1; } } } printf("%d/n",k); }return 0;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 久久亚洲视频网 | 欧美成人精品欧美一级乱黄 | 久久久久国产成人精品亚洲午夜 | 一区二区久久精品66国产精品 | 亚洲91精品 | china对白普通话xxxx | 中文字幕在线观看成人 | 欧美高清一级片 | 成年人视频免费 | 2019中文字幕在线播放 | 99这里精品 | 国产成人免费精品 | 黄视频免费在线观看 | 国产噜噜噜噜噜久久久久久久久 | free japan xxxxhdsex69 | 黄色伊人网站 | 黄色片在线播放 | 亚洲第一页综合 | 港台三级在线观看 | 欧美成人一区二区视频 | 国产精品成人久久久久a级 欧美特黄一级高清免费的香蕉 | 毛片区| 康妮卡特欧美精品一区 | 国产精品一区二区三区在线播放 | 色97在线| 久久无毛 | av免费在线观看国产 | 蜜桃网站免费 | 免费看真人a一级毛片 | 十级毛片 | 看免费5xxaaa毛片 | 性片久久| 国产精品久久久久久久久久久久午夜 | 欧美精品亚洲人成在线观看 | av电影手机在线看 | 成人做爰高潮片免费视频韩国 | 国产羞羞网站 | 久久精品久久久久 | 羞羞网站视频 | 亚洲日本高清 | 国产羞羞视频在线观看免费应用 |