题目:
You are given a sequence ?1,?2,…,??a1,a2,…,an consisting of ?n non-zero integers (i.e. ??≠0ai≠0).
You have to calculate two following values:
- the number of pairs of indices (?,?)(l,r) (?≤?)(l≤r) such that ??⋅??+1…??−1⋅??al⋅al+1…ar−1⋅ar is negative;
- the number of pairs of indices (?,?)(l,r) (?≤?)(l≤r) such that ??⋅??+1…??−1⋅??al⋅al+1…ar−1⋅ar is positive;
Input
The first line contains one integer ?n (1≤?≤2⋅105)(1≤n≤2⋅105) — the number of elements in the sequence.
The second line contains ?n integers ?1,?2,…,??a1,a2,…,an (−109≤??≤109;??≠0)(−109≤ai≤109;ai≠0) — the elements of the sequence.
Output
Print two integers — the number of subsegments with negative product and the number of subsegments with positive product, respectively.
Examples
input
5 5 -3 3 -1 1
output

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



