当前位置:网站首页>A. Vacations (dp 贪心
A. Vacations (dp 贪心
2022-06-13 07:18:00 【lcxdz】
添加链接描述
dp方程是选择健身 选择工作 选择比赛的最少休息天数
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int dp[N][5];//第i天选择休息,健身或者比赛的最少休息天数
int main(){
int n;
cin>>n;
memset(dp,0x3f,sizeof dp);
int x;
dp[0][0]=dp[0][1]=dp[0][2]=0;
for(int i=1;i<=n;i++){
cin>>x;
dp[i][0]=min({
dp[i-1][1],dp[i-1][0],dp[i-1][2]})+1;
if(x==1||x==3){
dp[i][2]=min(dp[i-1][0],dp[i-1][1]);
}
if(x==2||x==3){
dp[i][1]=min(dp[i-1][2],dp[i-1][0]);
}
}
cout<<min({
dp[n][0],dp[n][1],dp[n][2]});
return 0;
}
边栏推荐
- Problems encountered during commissioning of C # project
- Monotone stack top31 of interview must brush algorithm top101
- Br backup test
- Yolov5 analysis | parameters and performance indicators
- Real time lighting of websocket server based on esp32cam
- Table access among Oracle database users
- C drawing table and sending mail function
- FSM state machine
- redis-0. Introduction to redis and NiO principle (random talk)
- redis-3. Redis list, set, hash, sorted_ set、skiplist
猜你喜欢
2022-06-12:在N*N的正方形棋盘中,有N*N个棋子,那么每个格子正好可以拥有一个棋子。 但是现在有些棋子聚集到一个格子上了,比如: 2 0 3 0 1 0 3 0 0 如上的二维数组代表,一
How worker threads in the thread pool are recycled
Tidb dashboard modify port
Micro isolation (MSG)
Implementation of fruit mall wholesale platform based on SSM
Table access among Oracle database users
Tikv key performance parameters and optimization
Ticdc introduction
简单了解C语言基本语
【微弱瞬态信号检测】混沌背景下微弱瞬态信号的SVM检测方法的matlab仿真
随机推荐
Host computer development (Architecture Design of firmware download software)
Word document export
Detailed description of drawing ridge plot, overlapping densities of overlapping kernel density estimation curve, facetgrid object and function sns Kdeplot, function facetgrid map
尝试使用RenderDoc查看UE的Shader代码
Relevant knowledge under WinForm
个人js学习笔记
Postgraduate entrance examination English
MySQL query timeout control
关于c#委托、事件相关问题
[RS-422 and RS-485] RS-422 and RS-485 serial interface standard
【RS-422与RS-485】RS-422与RS-485串行接口标准
DM Experiment 6: filter replication
Fe of mL: introduction to vintage curve /vintage analysis, calculation logic and detailed introduction to case application
Try to use renderdoc to view the shader code of UE
C # using multithreading
oracle问题,字段里面的数据被逗号隔开,取逗号两边数据
redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed
基于ESP32CAM实现WebSocket服务器实时点灯
2022 - 06 - 12: dans un échiquier carré n * N, il y a n * n pièces, donc chaque pièce peut avoir exactement une pièce. Mais maintenant quelques pièces sont rassemblées sur une grille, par exemple: 2 0
Related operations under Oracle Database