太猛了,剛考完題目就出來了:D,氣死剛剛想好久
下面隨便打的參考參考
#include <bits/stdc++.h>
#define fast_as_a_fuckboy ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main() {
fast_as_a_fuckboy
int n, w1, w2, h1, h2;
cin >> n >> w1 >> w2 >> h1 >> h2;
int vol[2], nh[n];
vol[0] = w1*w1*h1;
vol[1] = w2*w2*h2;
int now = 0;
int v[n];
for(int i = 0;i < n;i++){
cin >> v[i];
}
for(int i = 0;i < n;i++){
now += v[i];
if(vol[0] > now){
nh[i] = now/w1/w1;
}
else if(vol[0] + vol[1] > now){
nh[i] = (now-vol[0])/w2/w2 + h1;
}
else{
nh[i] = h1+h2;
}
}
int ans = nh[0];
for(int i = 1;i < n;i++){
ans = max(ans, nh[i] - nh[i-1]);
}
cout << ans;
}