题解 | 卡牌游戏

卡牌游戏

https://www.nowcoder.com/practice/717961865ee54e7e8839c0b93b6ee597

#include <iostream>
using namespace std;
long long a[100000];
int main(){
int n;
cin>>n;
if(n<2){
    cout<<0;
}
else{long long c=0;
    for(int i=1;i<=n;i++){
int b;
cin>>b;


a[i]=a[i-1]+b;
if(a[i]>0){
c+=a[i];


}


    }
if(a[1]>=0){
cout<<c-a[1];
}
    
    else{
        cout<<c;
    }
}



    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务