100pts但是unac

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

miss_zhangxh @ 2024-11-12 21:42:41

Subtask #1 RE了TT

#include<bits/stdc++.h>
using namespace std;
int a[1000005];
multiset<int>ch;
vector<int>minn;
vector<int>maxn;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(i<=k)
        ch.insert(a[i]);
    }
    minn.push_back(*ch.begin());
    maxn.push_back(*ch.rbegin());
    for(int i=1;i<=n-k;i++){
        ch.insert(a[k+i]);
        ch.erase(a[i]);
        minn.push_back(*ch.begin());
        maxn.push_back(*ch.rbegin());
    }
    for(int i=0;i<=n-k;i++){
        printf("%d ",minn[i]);
    }
    cout<<endl;
    for(int i=0;i<=n-k;i++){
            printf("%d ",maxn[i]);
        }
        return 0;
}

by Qiner @ 2024-11-19 21:23:30

看不懂?


|