友情提示

P1440 求m区间内的最小值

KALY @ 2020-02-03 13:36:25

此题由于要输出输入很多数据使用cin cout会裂开
(并不是STL的锅)


by Qquun @ 2020-02-21 11:14:41

楼主可尝试把endl替换成"\n"


by 庄nnnn额 @ 2021-08-24 21:45:16

#include <bits/stdc++.h>
using namespace std;
vector<int> q;
int a[2000005];
int main(){
    int n;
    unsigned m;
    scanf("%d%u",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    printf("0");
    for(int i=2;i<=n;i++){
        if(q.size()==m)
            q.erase(q.begin());
        while(q.back()>=a[i]&&!q.empty())
            q.pop_back();
        q.push_back(a[i]);
        printf("\n%d",q.front());
    }
    return 0;
}

if(q.size()==m)那段RE。vector::size()函数返回值为unsigned,我的m也用unsigned,为什么RE!


上一页 |