当前位置:网站首页>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;
}
边栏推荐
- 大二下个人发展小结
- Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
- 【案例】定位的运用-淘宝轮播图
- Aitm2-0002 12s or 60s vertical combustion test
- Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
- Influence of oscilloscope probe on signal source impedance
- Chapter 05_ Storage engine
- SYSTEMd resolved enable debug log
- EasyExcel的讀寫操作
- Two ways to realize video recording based on avfoundation
猜你喜欢

显示屏DIN 4102-1 Class B1防火测试要求

Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved

Access Zadig self-test environment outside the cluster based on ingress controller (best practice)

Deployment of Jenkins under win7

Display DIN 4102-1 Class B1 fire test requirements

Teach yourself to train pytorch model to Caffe (I)

基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session

Opérations de lecture et d'écriture pour easyexcel

事项研发工作流全面优化|Erda 2.2 版本如“七”而至

Golang(1)|从环境准备到快速上手
随机推荐
Teach yourself to train pytorch model to Caffe (2)
【案例】定位的运用-淘宝轮播图
LeetCode: Distinct Subsequences [115]
第05章_存储引擎
EasyExcel的读写操作
How to prepare for the algorithm interview and answer the algorithm interview questions
XML modeling
Is Kai Niu 2980 useful? Is it safe to open an account
Learning notes of SAS programming and data mining business case 19
Golang (1) | from environmental preparation to quick start
【案例】元素的显示与隐藏的运用--元素遮罩
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
2022-07-03-cka- latest feedback from fans
Clion-MinGW编译后的exe文件添加ico图标
Introduction of ArcGIS grid resampling method
Comparison table of foreign lead American abbreviations
Introduction to TS, constructor and its this, inheritance, abstract class and interface
What are the requirements of UL 2043 test for drive housing in the United States?
MySQL 千万数据量深分页优化, 拒绝线上故障!
Postgres establish connection and delete records