1215B. The Number of Products
生活随笔
收集整理的這篇文章主要介紹了
1215B. The Number of Products
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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; }總結(jié)
以上是生活随笔為你收集整理的1215B. The Number of Products的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IDEA设置护眼浅绿色背景
- 下一篇: IT项目管理规范模板及IT软件招投标模板