当前位置:网站首页>Greedy distribution problem (2)
Greedy distribution problem (2)
2022-06-22 22:40:00 【Douglas_ LT】
A daily topic ing, Today is a day hard topic Power button 135. Candy
class Solution {
public:
int candy(vector<int>& ratings) {
int min=0;
vector<int> mark;
for(int i=0;i<ratings.size();i++)
{
mark.push_back(1);
}
for(int i=ratings.size()-2;i>=0;i--)
{
if(ratings[i]>ratings[i+1])
{
mark[i]=mark[i+1]+1;
}
}
for(int i=1;i<=ratings.size()-1;i++)
{
if(ratings[i]>ratings[i-1])
{
mark[i]=mark[i]>mark[i-1]+1?mark[i]:mark[i-1]+1;
}
}
for(int i=0;i<=ratings.size()-1;i++)
{
min=min+mark[i];
}
return min;
}
};
边栏推荐
- [geometric vision] 4.2 piecewise linear transformation
- [GWCTF 2019]mypassword XSS
- Redis error reporting and common configurations
- Self service library system Tkinter interface and openpyxl form comprehensive design case
- MySQL multi table operation
- Home page navigation + left menu of spa project development
- Plan and change of continuous repair
- Atcoder abc256 full problem solution (interval merging template, matrix fast power optimization DP, line segment tree...)
- Cryptography series: certificate format representation of PKI X.509
- What are the methods of software stress testing and how to select a software stress testing organization?
猜你喜欢

Adblock blocks Baidu hot search
Task cache compilation caused by gradle build cache

Reasons for the failure of digital transformation and the way to success
A hundred lines of code to realize reliable delay queue based on redis

Plan and change of continuous repair

What are the indicators, dimensions and models in Business Intelligence BI data warehouse?
![[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design](/img/5d/71c75a3622f7814f385d04b6148074.png)
[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design

The xinjietu x70s has been listed for 87900 times and has leapfrogged the class in space safety. It is worthy of being a 7-seat SUV of the National University of China
![下一个排列[发挥主观能动性发现规律]](/img/bb/262e1a21e4babb8d221d737ced3bcc.png)
下一个排列[发挥主观能动性发现规律]
![组合总数[标准回溯 + 回溯技巧--降低栈深度]](/img/88/3a07589bf8edab618139b1bf1680e8.png)
组合总数[标准回溯 + 回溯技巧--降低栈深度]
随机推荐
[path planning] week 1: hodgepodge
pycharm 配置远程连接服务器开发环境
Dragon City in Europe | National Geographic the most romantic and safe destination in the world
In the third week of June, the main growth ranking list (BiliBili platform) of station B single feigua data up was released!
Rapideye, spot satellite remote sensing image data
下一个排列[发挥主观能动性发现规律]
Seriously, the hang up of the kotlin collaboration process is not so mysterious (principle)
SQL performance optimization method for interval retrieval
卸载mavros
Mask image modeling for self supervised representation pre training: CAE and its relationship with Mae and Beit
Eureka服务注册与发现
【几何法视觉】4.2 分段线性变换
June25,2022 PMP Exam clearance manual-6
sitl_ gazebo/include/gazebo_ opticalflow_ plugin. h:43:18: error: ‘TRUE’ was not declared in this scope
5 minutes to quickly launch web applications and APIs (vercel)
R language builds a binary classification model based on H2O package: using H2O GLM constructs regularized logistic regression model and uses H2O AUC value of AUC calculation model
自监督表征预训练之掩码图像建模:CAE 及其与 MAE、BEiT 的联系
Generate detailed API and parameters of QR code using qrcodejs2
RapidEye快鸟、SPOT卫星遥感影像数据
Live broadcast forecast the sixth issue of the webinfo lecture hall of the China Information Association will be broadcast on June 24