这段代码为什么 CE?
  • 板块学术版
  • 楼主__vector__
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/10/31 18:06
  • 上次更新2023/11/2 10:32:17
查看原帖
这段代码为什么 CE?
507348
__vector__楼主2023/10/31 18:06

C 语言,不是 C++。
本蒟蒻对 C 和 C++ 的区别了解很少,见谅

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
typedef long long ll;
const int maxn=2e5+5;
int t;
int n;
ll c;
ll a[maxn];
ll pre[maxn];
ll w(int l,int r)
{
    return pre[r]-pre[l-1];
}
bool chk(int pos)
{
    if(w(pos,n)<ll(pos)*(pos+1)*c)return 0;
    if(pos+1==n)return 1;
    return chk(pos+1);
}
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%lld",&n,&c);
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
            pre[i]=pre[i-1]+a[i];
        }
        puts(chk(1)?"YES":"NO");
    }
    return 0;
}
2023/10/31 18:06
加载中...