首页 > 其他分享 >C. Theofanis' Nightmare

C. Theofanis' Nightmare

时间:2024-03-27 17:48:34浏览次数:29  
标签:suf int Theofanis long Nightmare ans ll

原题链接

题解

太巧妙了!!
层加式?

code

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100005]={0};
int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        ll suf=a[n],ans=a[n];
        for(int i=n-1;i>=1;i--)
        {
            ans+=max(a[i],a[i]+suf);
            suf+=a[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

标签:suf,int,Theofanis,long,Nightmare,ans,ll
From: https://www.cnblogs.com/pure4knowledge/p/18099836

相关文章

  • CF1800F Dasha and Nightmares 题解
    分析考虑枚举。注意到第二个条件是必须要有$25$个字符在里面出现过,故考虑枚举唯一没出现过的字符$k$,然后再枚举$s_i$。令$cnt_{i,j}$表示$s_i$中字符$c$出现的奇偶性。如果有字符$c\nek\landcnt_{i,c}=0$,则在$s_j$中必有$cnt_{j,c}=1$;反之同理。枚举字符$c......
  • F. Dasha and Nightmares
    F.DashaandNightmaresDasha,anexcellentstudent,isstudyingatthebestmathematicallyceuminthecountry.Recently,amysteriousstrangerbrought$n$wo......
  • HDU 3085 Nightmare Ⅱ
    ProblemDescriptionLastnight,littleerriyuehadahorriblenightmare.Hedreamedthatheandhisgirlfriendweretrappedinabigmazeseparately.Mo......
  • HDU3085 Nightmare Ⅱ
    DescriptionlinkSolution这是个双向广搜板子题。首先鬼的分裂实际上就是每一次走两步,由于没有障碍所以直接曼哈顿距离即可。男孩每一次可以走3步,所以直接bfs连走......