代码本地能正常运行,但在线ide会CE
查看原帖
代码本地能正常运行,但在线ide会CE
1189340
aishiteru_mitsu_ha楼主2025/7/28 15:33

rt

#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define N 100086
using namespace std;
int n;
priority_queue<int,vector<int>,greater<int> >small;
priority_queue<int,vector<int>,less<int> >big;
inline int read();
int main(){
    n=read();
    big.push(read());
    cout<<big.top()<<endl;
    for(int i=2;i<=n;i++){
        int x=read();
        if(x<=big.top()) big.push(x);
        else small.push(x);
        if(abs(small.size()-big.size())>1){
            if(small.size()>big.size()){
                big.push(small.top());
                small.pop();
            }else{
                small.push(big.top());
                big.pop();
            }
        }
        if(i%2){
            cout<<(small.size()>big.size()?small.top():big.top())<<endl;
        }
    }
    return 0;
}
inline int read(){
    int 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-48;ch=getchar();}
    return x*f;
}

在luogu在线ide上运行显示

/tmp/compiler_chkujsae/src: In function ‘int main()’:
/tmp/compiler_chkujsae/src:18:15: 错误:调用重载的‘abs(std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type)’有歧义
   18 |         if(abs(small.size()-big.size())>1){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/cstdlib:79,
                 from /nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/stdc++.h:42,
                 from /tmp/compiler_chkujsae/src:1:
/nix/store/x8lqlydsxbrwvf6p7v18gws8kn1xl37f-glibc-2.38-23-dev/include/stdlib.h:980:12: 附注:candidate: ‘int abs(int)’
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/cstdlib:81:
/nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/bits/std_abs.h:79:3: 附注:candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/bits/std_abs.h:75:3: 附注:candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/bits/std_abs.h:71:3: 附注:candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/bits/std_abs.h:61:3: 附注:candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/nix/store/al0w33yvyzkjm86ndpf42knjfymfisph-luogu-gcc-13.2.0/include/c++/13.2.0/bits/std_abs.h:56:3: 附注:candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~

2025/7/28 15:33
加载中...