样例过,但0分!?

P1440 求m区间内的最小值

coritom @ 2024-02-19 16:52:52

#include<bits/stdc++.h>
using namespace std;
int n, m, a[2000005];
deque<int> dq;
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    if(n > 1) cout << "0\n" << a[1] << "\n";
    else cout << 0;
    for(int i = 1; i < n; i++){
        while(!dq.empty() && i - dq[0] >= m) dq.pop_front();
        while(!dq.empty() && a[dq.back()] > a[i]) dq.pop_back();
        dq.push_back(i);
        if(i >= m){
            cout << a[dq[0]] << "\n";
        }
    }
    return 0;
}

by coritom @ 2024-02-19 17:07:05

已AC


|