Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 求dalao看下为啥会MLE

Posted by dmk12345678 at 2017-09-12 19:27:20 on Problem 2823
```#include<iostream>
using namespace std;
const int maxn=1000001;
struct zhangchen
{
int max,min;
}A[maxn][30];
int B[maxn],C[maxn];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
scanf("%d",&A[i][0].max),A[i][0].min=A[i][0].max;
for(int j=1;j>0;j++)
{
if((1<<j)>n)break;
for(int i=1;i<=n-(1<<j)+1;i++)
{
A[i][j].max=max(A[i+(1>>j-1)][j-1].max,A[i][j-1].max);
A[i][j].min=min(A[i+(1>>j-1)][j-1].min,A[i][j-1].min);
}
}
int l=1,r=k;
for(int i=1;i>0;i++)
{
if((1<<i)>k)
{
k=i-1;
break;
}
}
while(1)
{

B[l]=max(A[l][k].max,A[r-(1<<k)+1][k].max);
C[l]=min(A[l][k].min,A[r-(1<<k)+1][k].min);
l++,r++;
if(r>n)break;
}
for(int i=1;i<l;i++)
printf("%d ",C[i]);
cout<<endl;
for(int i=1;i<l;i++)
printf("%d ",B[i]);
//system("pause");
return 0;
}
```

Followed by: