#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9;
int N;
ll Ans;
int Tree_A[1<<12],Tree_B[1<<12];
int update(int *tree,int s,int e,int idx,int v,int n){
if (idx<s||e<idx)
return tree[n];
if (s==e)
return tree[n]=v;
int m=(s+e)>>1;
return tree[n]=min(update(tree,s,m,idx,v,n<<1),update(tree,m+1,e,idx,v,n<<1|1));
}
int query(int *tree,int s,int e,int l,int r,int n){
if (e<l||r<s)
return INF;
if (l<=s&&e<=r)
return tree[n];
int m=(s+e)>>1;
return min(query(tree,s,m,l,r,n<<1),query(tree,m+1,e,l,r,n<<1|1));
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N;
for (int i=1; i<=N; i++){
int a,b;
cin>>a>>b;
update(Tree_A,1,N,i,a,1);
update(Tree_B,1,N,i,b,1);
}
for (int i=1; i<=N; i++){
for (int j=i; j<=N; j++)
Ans=max(Ans,(ll)(j-i+1)*query(Tree_A,1,N,i,j,1)*query(Tree_B,1,N,i,j,1));
}
cout<<Ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
450 ms |
336 KB |
Output is correct |
2 |
Correct |
498 ms |
452 KB |
Output is correct |
3 |
Correct |
482 ms |
332 KB |
Output is correct |
4 |
Correct |
473 ms |
332 KB |
Output is correct |
5 |
Correct |
408 ms |
332 KB |
Output is correct |
6 |
Correct |
525 ms |
332 KB |
Output is correct |
7 |
Correct |
502 ms |
332 KB |
Output is correct |
8 |
Correct |
442 ms |
332 KB |
Output is correct |
9 |
Correct |
543 ms |
332 KB |
Output is correct |
10 |
Correct |
600 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
204 KB |
Output is correct |
12 |
Correct |
529 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
450 ms |
336 KB |
Output is correct |
2 |
Correct |
498 ms |
452 KB |
Output is correct |
3 |
Correct |
482 ms |
332 KB |
Output is correct |
4 |
Correct |
473 ms |
332 KB |
Output is correct |
5 |
Correct |
408 ms |
332 KB |
Output is correct |
6 |
Correct |
525 ms |
332 KB |
Output is correct |
7 |
Correct |
502 ms |
332 KB |
Output is correct |
8 |
Correct |
442 ms |
332 KB |
Output is correct |
9 |
Correct |
543 ms |
332 KB |
Output is correct |
10 |
Correct |
600 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
204 KB |
Output is correct |
12 |
Correct |
529 ms |
332 KB |
Output is correct |
13 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |