B. The Number of Products:题目
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> a((int)6e5);
signed main()
{int n;cin>>n;for (int i=1;i<=n;i++) cin>>a[i];vector<int>dp(3);dp[1] = dp[2] = 0;int res1 = 0,res2 = 0;for (int i=1;i<=n;i++){vector<int>ndp(3);if (a[i]>0) ndp[1] = dp[1]+1,ndp[2] = dp[2];else ndp[2] = dp[1]+1,ndp[1] = dp[2];res1+=ndp[1];res2+=ndp[2];swap(ndp,dp);}cout<<res2<<" "<<res1<<endl;
}