洛谷10分求助……

P1440 求m区间内的最小值

liufukang @ 2021-01-02 13:27:55

这是学校OJ作业的一道题,提交编译全部RE,错误报告令我很懵……

Runtime Error:Alarm clock
Runtime Error:[ERROR] A Not allowed system call: runid:54551 CALLID:240
 TO FIX THIS , ask admin to add the CALLID into corresponding LANG_XXV[] located at okcalls32/64.h ,
and recompile judge_client. 
if you are admin and you don't know what to do ,
chinese explaination can be found on https://zhuanlan.zhihu.com/p/24498599

Runtime Error:Alarm clock
Runtime Error:[ERROR] A Not allowed system call: runid:54551 CALLID:240
 TO FIX THIS , ask admin to add the CALLID into corresponding LANG_XXV[] located at okcalls32/64.h ,
and recompile judge_client. 
if you are admin and you don't know what to do ,
chinese explaination can be found on https://zhuanlan.zhihu.com/p/24498599

Runtime Error:[ERROR] A Not allowed system call: runid:54551 CALLID:240
 TO FIX THIS , ask admin to add the CALLID into corresponding LANG_XXV[] located at okcalls32/64.h ,
and recompile judge_client. 
if you are admin and you don't know what to do ,
chinese explaination can be found on https://zhuanlan.zhihu.com/p/24498599`

……

然后在洛谷提交是10分……

我的代码:

#include<bits/stdc++.h>
using namespace std;
const int maxN=1e6+10;
deque<int>q;//记录数字位置
long long n,k,a[maxN];
long long read();
void write(int),work();
int main(){
    n=read();k=read();
    for (int i=1;i<=n;i++) a[i]=read();//读入
    for (int i=1;i<k;i++) cout<<0<<endl;//前k-1个输出为0
    cout<<a[k-1]<<endl;//第k个输出
    work();
    return 0;
}
inline void work(){
    q.clear();//清空队列(不要也行)
    for (int i=1;i<n;i++){
        while (!q.empty()&&q.front()<=i-k) q.pop_front();//如果不是空队列,并且队首的编号小于区间内最小的编号,就弹出
        while (!q.empty()&&a[q.back()]>=a[i]) q.pop_back();//如果队内有比该数大的就弹出,保证队内的数始终保持从小到大的单调性
        q.push_back(i);//入队
        if (i>=k) write(a[q.front()]),puts("");//如果当前数的编号比区间范围(即题目所说的m,我这用的k)大,就让队首出队
    }
    puts("");//换行
}//从我某道AC的同类题上截下来修改得到的
inline long long read(){
    long long s=0;
    int f=1;
    char ch=getchar();
    while (!isdigit(ch)){
        if (ch=='-') f=-1;
        ch=getchar();
    }
    while (isdigit(ch)){
        s=s*10+(ch-'0');
        ch=getchar();
    }
    return s*f;
}//快读函数
inline void write(int x){
    if (x<0){
        putchar('-');
        x=-x;
    }
    if (x>9){
        write(x/10);
        putchar(x%10+'0');
        return;
    }
    putchar(x+'0');
}//快写函数
/*
6 2
7 8 1 4 3 2
*/

求大佬神助!!orz


by liufukang @ 2021-01-02 13:37:47

评测记录


|