weixin_50947427 2021-09-04 20:20 采纳率: 66.7%
浏览 312
已结题

程序运行时出现错误,因exception已暂停

程序在运行过程中出现错误,然后我用vs code调试了一下,看到什么因EXCEPTION已暂停。不是很懂啥情况。
代码:

#include<iostream>
#include<cstring>
using namespace std;
#define ll long long
const int maxn=1000010; 
int a[1000010]={0};
int n,k;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

void max1(){
    int q[maxn],p[maxn],head,tail;
    memset(q,0,sizeof(q));
    head=1;tail=0;              
    for(int i=1;i<=n;i++){
        while(a[i]>=q[tail]&&head<=tail){
            tail--;
        }
        q[++tail]=a[i];
        p[tail]=i;
        while(p[head]<=i-k){
            head++;
        }
        if(i>=k){
            cout<<q[head]<<' ';
        }
    }
    cout<<endl;
    return ;
}

void min1(){
    int q[maxn],p[maxn],head,tail;
    memset(q,0,sizeof(q));
    head=1;tail=0;              
    for(int i=1;i<=n;i++){
        while(a[i]<=q[tail]&&head<=tail){
            tail--;
        }
        q[++tail]=a[i];
        p[tail]=i;
        while(p[head]<=i-k){
            head++;
        }
        if(i>=k){
            cout<<q[head]<<' ';
        }
    }
    cout<<endl;
    return ;
}

int main(){
    n=read();
    k=read();
    for(int i=1;i<=n;i++){
        a[i]=read();
    }
    min1();
    max1();
    return 0;
}


输入:
8 3
1 3 -1 -3 5 3 6 7

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 9月12日
    • 创建了问题 9月4日

    悬赏问题

    • ¥15 单纯型python实现编译报错
    • ¥15 c++2013读写oracle
    • ¥15 c++ gmssl sm2验签demo
    • ¥15 关于模的完全剩余系(关键词-数学方法)
    • ¥15 有没有人懂这个博图程序怎么写,还要跟SFB连接,真的不会,求帮助
    • ¥15 PVE8.2.7无法成功使用a5000的vGPU,什么原因
    • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
    • ¥15 安装quartus II18.1时弹出此error,怎么解决?
    • ¥15 keil官网下载psn序列号在哪
    • ¥15 想用adb命令做一个通话软件,播放录音