找出来个类似的,快来卡
#include<bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
int n,lg[N];
int dp_a[N][25],dp_b[N][25];
ll ans=0;
int query_a(int l,int r){
int k=lg[r-l+1];
return min(dp_a[l][k],dp_a[r-(1<<k)+1][k]);
}
int query_b(int l,int r){
int k=lg[r-l+1];
return min(dp_b[l][k],dp_b[r-(1<<k)+1][k]);
}
vector<int> v;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
scanf("%d%d",&dp_a[i][0],&dp_b[i][0]);
v.push_back(i);
}
for(int i=2;i<=n;i++){
lg[i]=lg[i>>1]+1;
}
for(int i=1;i<21;i++){
for(int j=1;j+(1<<i)-1<=n;j++){
dp_a[j][i]=min(dp_a[j][i-1],dp_a[j+(1<<i-1)][i-1]);
dp_b[j][i]=min(dp_b[j][i-1],dp_b[j+(1<<i-1)][i-1]);
}
}
random_shuffle(v.begin(),v.end());
for(auto i:v){
for(ll j=i;j<=n;j++){
ll x=1ll*query_a(i,j)*query_b(i,j);
ans=max(ans,x*(j-i+1));
j=(ans/x)+i-1;
}
}
cout<<ans;
return 0;
}
@linan024