#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, w1, w2, h1, h2, V, under=0, up=0,sum=0, change=0;
//水量
vector <int>Siesta;
//高度
vector <int>siesta;
cin >> n >> w1 >> w2 >> h1 >> h2;
//底面積
under=pow(w1,2);
up=pow(w2,2);
//輸入每次裝水量
for(int times=0;times<n;times++)
{
cin >>V;
Siesta.push_back(V);
}
//高度目前到哪的測試
for(int times=0;times<n;times++)
{
sum=sum+Siesta[times];
//是否有超過底下的體積
if(under*h1>sum)
{
siesta.push_back(sum/under);
}
else if(under*h1<sum)
{
//如果有超過底下的體積 那是否上方也有超過
if(sum<under*h1+up*h2)
{
siesta.push_back(h1+(sum-under*h1)/up);
}
else if(under*h1+up*h2<=sum)
{
siesta.push_back(h1+h2);
break;
}
}
}
//找出水量變化量的最大值
change=siesta[0];
for(int times=0;times<siesta.size()-1;times++)
{
change=max(change,siesta[times+1]-siesta[times]);
}
cout <<change;
return 0;
}
#include
using namespace std;
int main()
{
int n, w1, w2, h1, h2, V, under=0, up=0,sum=0, change=0;
//水量
vector Siesta;
//高度
vector siesta;
cin >> n >> w1 >> w2 >> h1 >> h2;
//底面積
under=pow(w1,2);
up=pow(w2,2);
//輸入每次裝水量
for(int times=0;times {
cin >>V;
Siesta.push_back(V);
}
//高度目前到哪的測試
for(int times=0;times {
sum=sum+Siesta[times];
//是否有超過底下的體積
if(under*h1>sum)
{
siesta.push_back(sum/under);
}
else if(under*h1 {
//如果有超過底下的體積 那是否上方也有超過
if(sum {
siesta.push_back(h1+(sum-under*h1)/up);
}
else if(under*h1+up*h2<=sum)
{
siesta.push_back(h1+h2);
break;
}
}
}
//找出水量變化量的最大值
change=siesta[0];
for(int times=0;times {
change=max(change,siesta[times+1]-siesta[times]);
}
cout < return 0;
}
if ( under*h1>sum)
{
(省略)
}
else if(under*h1<sum)
這裡未考慮到相等的情況。
elif (under*h1<sum)