当前位置:网站首页>A. Vacations (DP greed
A. Vacations (DP greed
2022-06-13 07:18:00 【lcxdz】
Add link description
dp The equation is choosing fitness Choose a job Choose the minimum number of days off for the game
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int dp[N][5];// The first i Days off , Minimum rest days for fitness or competition
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;
}
边栏推荐
- ISIS的vsys(虚拟系统)
- Upper computer development (code debugging of firmware download software)
- The biggest highlight of wwdc2022: metalfx
- 线程池中的 工作线程如何被回收
- Xuanwu cloud technology passed the listing hearing: the performance fluctuated significantly, and chenyonghui and other three were the controlling shareholders
- Tidb implementation plan -- III
- Evolution in the digital age
- 基于SSM实现水果商城批发平台
- RT thread simulator lvgl control: button button event
- 【RS-422与RS-485】RS-422与RS-485串行接口标准
猜你喜欢

简单了解C语言基本语

redis-1. Install redis with pictures and texts

线程池中的 工作线程如何被回收

Tidb statistics

Continuous management design

Compilation and development process of Quanzhi v3s environment

FSM state machine

Real time lighting of websocket server based on esp32cam

Tidb grafana reverse proxy

RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
随机推荐
杭州证券开户是安全的吗?
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
Database connection under WinForm
Related operations under Oracle Database
Detailed description of drawing ridge plot, overlapping densities of overlapping kernel density estimation curve, facetgrid object and function sns Kdeplot, function facetgrid map
. Net code to implement get request and post request
June 12, 2022: if there are n*n pieces in an n*n square chessboard, each grid can have exactly one piece. But now some pieces are gathered on a grid, such as 2030100300. The above two-dimensional arra
redis-2. Redis string type & bitmap
C # related knowledge points
10 Honest Facts I Want To Share With All Junior Developers
Oracle problem: the data in the field is separated by commas. Take the data on both sides of the comma
快速排序
mysql中时间字段 比较时间大小
[turn to] FPGA interview questions
Uploading and retrieving stored images in localstorage
简单了解C语言基本语
RT-Thread 模拟器 simulator LVGL控件:button 按钮事件
Try to use renderdoc to view the shader code of UE
Que se passe - t - il si les produits financiers sont nuls pendant plusieurs jours?
JMeter encryption interface test