建议降红
查看原帖
建议降红
1243618
Jokersheng楼主2024/9/7 21:59

什么贪心二分前缀和的,不就是个数论+模拟吗?

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

const int N=114514;

int n,a[N],s,res;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		s+=a[i];
		if(s<0){
			res-=s;
			s=0;
		}
	}
	cout<<res+1;
	
	
	return 0;
}

@simple_child

2024/9/7 21:59
加载中...