2019-11-07 12:48
东华大学 算法工程师 0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享
2019-08-17 22:14
东华大学 算法工程师 hlmmd:#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> work(n, 0);
vector<int> play(n, 0);
int dp1, dp2, lp1, lp2;
dp1 = dp2 = lp1 = lp2 = 0;
for (int i = 0; i < n; i++)
cin >> work[i];
for (int i = 0; i < n; i++)
cin >> play[i];
for (int i = 0; i < n; i++)
{
lp1 = dp1;
lp2 = dp2;
if (work[i] == 0 && play[i] == 0)
{
dp2 = dp1 = max(lp1, lp2);
}
else if (work[i] == 1 && play[i] == 1)
{
dp1 = max(lp1, lp2 + 1);
dp2 = max(lp2, lp1 + 1);
}
else if (work[i] == 1)
{
dp2 = max(lp1, lp2);
dp1 = max(lp1, lp2 + 1);
}
else
{
dp1 = max(lp1, lp2);
dp2 = max(lp2, lp1 + 1);
}
}
cout << n - max(dp1, dp2) << endl;
system("pause");
return 0;
} AC
投递腾讯等公司10个岗位 >
0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享
关注他的用户也关注了: