傳送門:acdream 1240
給定一個由1,-1組成的環,問有多少個點滿足,從該點開始無論連續選多少個點,其和都爲正數
假如所有數都是1,那麼所有數都滿足條件
給的數中每出現一個-1,那麼就會有一個位置的1也變得不滿足條件,因此最終答案就是n-2*cnt,(cnt爲-1個數)
/******************************************************
* File Name: f.cpp
* Author: kojimai
* Creater Time:2014年10月07日 星期二 13時31分42秒
******************************************************/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int n,x;
scanf("%d",&n);
int cnt = 0;
for(int i = 0;i < n;i++)
{
scanf("%d",&x);
if(x == -1)
cnt++;
}
int ans = n - cnt * 2;
if(ans < 0)
ans = 0;
cout<<ans<<endl;
return 0;
}