QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#570221#6564. Frequent FlierUESTC_DECAYALI#Compile Error//Python3788b2024-09-17 14:48:142024-09-17 14:48:17

Judging History

你现在查看的是最新测评结果

  • [2024-09-17 14:48:17]
  • 评测
  • [2024-09-17 14:48:14]
  • 提交

answer

#include<cstdio>
#include<iostream>
#define int long long
#define RI register int
#define CI const int&
using namespace std;
const int N=400005;
int n,m,k,f[N],g[N],fa[N];
inline int getfa(CI x)
{
    return fa[x]!=x?fa[x]=getfa(fa[x]):x;
}
signed main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for (RI i=1;i<=n;++i) scanf("%lld",&f[i]);
    for (RI i=1;i<=n+m;++i) fa[i]=i;
    int sum=0,ans=0;
    for (RI i=1;i<=n+m-1;++i)
    {
        if (i-m>=1) sum-=g[i-m];
        if (sum>=k) continue;
        int x=getfa(i);
        while (x>0&&x>i-m&&sum<k)
        {
            int tmp=min(f[x]-g[x],k-sum);
            g[x]+=tmp; ans+=tmp; sum+=tmp;
            if (f[x]==g[x]) fa[x]=getfa(x-1),x=getfa(x);
        }
    }
    return printf("%lld",ans),0;
}

Details

  File "answer.code", line 6
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax