当前位置:网站首页>Li Kou ----- the maximum profit of operating Ferris wheel
Li Kou ----- the maximum profit of operating Ferris wheel
2022-07-05 21:22:00 【qq_ thirty-seven million seven hundred and sixty thousand seven】

int minOperationsMaxProfit(int* customers, int customersSize, int boardingCost, int runningCost){
int Record=0;
int top=0;
int stack[1000000];
int count=0;
int max=-10000;
int index;
for(int a=0;a<customersSize;a++){
Record=Record+customers[a];
if(Record>4){
count=count+4*boardingCost-runningCost;
stack[top++]=count;
Record=Record-4;
}
else{
count=count+customers[a]*boardingCost-runningCost;
stack[top++]=count;
Record=0;
}
if(stack[top-1]>max){
max=stack[top-1];
index=top-1;
}
}
if(Record>0){
while(1){
if(Record>4){
count=count+4*boardingCost-runningCost;
stack[top++]=count;
Record=Record-4;
}
else{
count=count+Record*boardingCost-runningCost;
stack[top++]=count;
if(stack[top-1]>max){
max=stack[top-1];
index=top-1;
}
break;
}
if(stack[top-1]>max){
max=stack[top-1];
index=top-1;
}
}
}
if(max<=0){
return -1;
}
return index+1;
}
边栏推荐
- LeetCode_哈希表_困难_149. 直线上最多的点数
- Monorepo management methodology and dependency security
- Sophomore personal development summary
- Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
- 秋招将临 如何准备算法面试、回答算法面试题
- 面试官:并发编程实战会吗?(线程控制操作详解)
- Aitm 2-0003 horizontal combustion test
- Selenium gets the verification code image in DOM
- EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
- 基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
猜你喜欢

Realize the function of verifying whether the user has completed login when browsing the page

Add ICO icon to clion MinGW compiled EXE file

Introduction of ArcGIS grid resampling method

Golang(1)|从环境准备到快速上手

Parker驱动器维修COMPAX控制器维修CPX0200H

示波器探头对信号源阻抗的影响

Teach yourself to train pytorch model to Caffe (2)

MySQL 千万数据量深分页优化, 拒绝线上故障!
![Longest swing sequence [greedy practice]](/img/e1/70dc21b924232c7e5e3da023a4bed2.png)
Longest swing sequence [greedy practice]

Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
随机推荐
LeetCode_ Hash table_ Difficulties_ 149. Maximum number of points on the line
123456
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
ODPs next map / reduce preparation
显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??
Binary search
Golang(1)|从环境准备到快速上手
Uni app Bluetooth communication
ArcGIS栅格重采样方法介绍
Teach yourself to train pytorch model to Caffe (III)
wpf 获取datagrid 中指定行列的DataGridTemplateColumn中的控件
Prior knowledge of machine learning in probability theory (Part 1)
PHP deserialization +md5 collision
R language [data management]
MySQL InnoDB Architecture Principle
Chapter 05_ Storage engine
100 cases of shell programming
Influence of oscilloscope probe on signal source impedance
Five layer network protocol
终端安全能力验证环境搭建和渗透测试记录