这题判死快读?
查看原帖
这题判死快读?
513900
Wilson_Lee楼主2022/2/10 13:55

开快读前: https://www.luogu.com.cn/record/68954527

开快读后: https://www.luogu.com.cn/record/68954961

各位dalao帮忙看一下我的快读没写错吧:

#include<bits/stdc++.h>
using namespace std;

const int MAXN=5e4+5;
int c[MAXN];
long long dp[MAXN];
inline void read(int &x)
{
    x=0;
    char ch=getchar();
    while(!isdigit(ch))
        ch=getchar();
    while(isdigit(ch))
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
}
int main()
{
    int n,l;
    read(n),read(l);
    for(int i=1;i<=n;++i)
    {
        read(c[i]);
        c[i]+=c[i-1];
    }
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=i;++j)
        {
            dp[i]=min(dp[i],dp[j-1]+(long long)(i-j+c[i]-c[j-1]-l)*(i-j+c[i]-c[j-1]-l));
        }
    }
    cout<<dp[n];
    return 0;
}
2022/2/10 13:55
加载中...