当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
How to send samples when applying for BS 476-7 display? Is it the same as the display??
Golang (1) | from environmental preparation to quick start
[case] Application of element display and hiding -- element mask
Écrire une interface basée sur flask
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
EasyExcel的读写操作
示波器探头对测量带宽的影响
让开发效率飞速提升的跨端方案
MySQL deep paging optimization with tens of millions of data, and online failure is rejected!
示波器探头对信号源阻抗的影响
随机推荐
第05章_存储引擎
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
R language [data management]
Selenium finds the contents of B or P Tags
PVC plastic sheets BS 476-6 determination of flame propagation properties
判断横竖屏的最佳实现
Parker driver maintenance COMPAX controller maintenance cpx0200h
Uni app Bluetooth communication
Postgres establish connection and delete records
Learning notes of SAS programming and data mining business case 19
Display DIN 4102-1 Class B1 fire test requirements
LeetCode_哈希表_困难_149. 直线上最多的点数
shell编程100例
AITM2-0002 12s或60s垂直燃烧试验
leetcode:1755. Sum of subsequences closest to the target value
PostGIS installation geographic information extension
Problems encountered in office--
Utils/index TS tool function
php中explode函数存在的陷阱
Écrire une interface basée sur flask