当前位置:网站首页>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;
}
边栏推荐
- Introduction and use of dumping
- Ml: introduction to stability analysis of machine learning model and detailed introduction to common solutions
- Upper computer development (software test of firmware download software)
- 理財產品連續幾天收益都是零是怎麼回事?
- How is it that the income of financial products is zero for several consecutive days?
- 【微弱瞬态信号检测】混沌背景下微弱瞬态信号的SVM检测方法的matlab仿真
- 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
- Que se passe - t - il si les produits financiers sont nuls pendant plusieurs jours?
- Tree list under winfrom treelist related
- SDN basic overview
猜你喜欢

Real time lighting of websocket server based on esp32cam

不间断管理设计

量化框架backtrader之一文读懂Analyzer分析器

Detailed description of drawing ridge plot, overlapping densities of overlapping kernel density estimation curve, facetgrid object and function sns Kdeplot, function facetgrid map

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

Evolution in the digital age

How to write an amazing design document?

【微弱瞬态信号检测】混沌背景下微弱瞬态信号的SVM检测方法的matlab仿真
![[vivefocus uses the wavevr plug-in to obtain handle operation events]](/img/4f/2ca02799ef5cde1a28101d61199856.jpg)
[vivefocus uses the wavevr plug-in to obtain handle operation events]

Ticdc introduction
随机推荐
Br tool backup recovery
Calculate running total / running balance
c#高级编程-特性篇
RT-Thread 模拟器 simulator LVGL控件:slider 控件
Relevant knowledge under WinForm
RT-Thread 模拟器 simulator LVGL控件:button 按钮事件
百货中心供应链管理系统
TiDB Lightning
ISIS的vsys(虚拟系统)
RT thread simulator lvgl control: button button event
RT thread simulator lvgl control: slider control
Time field comparison time size in MySQL
线程池中的 工作线程如何被回收
Simple understanding of basic language of C language
Tidb statistics
Quick sort
Local file upload FTP or remote directory
Upper computer development (detailed design of firmware download software)
Compilation and development process of Quanzhi v3s environment
基于ESP32CAM实现WebSocket服务器实时点灯