为什么暴力才得0分,请教大神

P1886 滑动窗口 /【模板】单调队列

drzo @ 2018-01-29 13:57:45

// luogu-judger-enable-o2
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int MAXN=10005;
int a[MAXN],b[MAXN];
int x(int a[],int n)
{
    int min=MAXN;
    for(int i=0; i<n; i++)
    {
        if(a[i]<=min)
        min=a[i];
    }
    return min;
}
int y(int a[],int n)
{
    int max=MAXN*-1;
    for(int i=0; i<n; i++)
    {
        if(a[i]>=max)
        max=a[i];
    }
    return max;
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n,k,i,j; 
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int c=0,min[n-k+1],max[n-k+1];
    for(i=0; i<=n-k; i++)
    {
        int t=0;
        for(j=i; j<i+3; j++)
        {
            b[t]=a[j];
            c++;
        }
        min[c]=x(b,n);
        max[c]=y(b,n);
        c++;
    }
    for(i=0; i<=c; i++)
    {
        cout<<min[i];
    }
    cout<<endl;
    for(i=0; i<=c; i++)
    {
        cout<<max[i];
    }
    cout<<endl;
    return 0;
}

by drzo @ 2018-01-29 13:58:29

急急急急急急


by strangers @ 2018-01-29 14:02:00

@teacherga

1.数组小了

2.而且您是暴力啊


by 老K @ 2018-01-29 14:07:26

这又不是考试/比赛,暴力为什么要拿分?


by panda_2134 @ 2018-04-01 12:35:42

@老K +1


|