CF719B Anatoly and Cockroaches

https://www.luogu.org/problemnew/show/CF719B

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<bits/stdc++.h>
using namespace std;

int n;
string s;
int a,b,c,d,ans;

int main(void)
{
cin >> n >> s;

for(int i = 0;i < n;++i)
{
if(i % 2 == 0)
{
if(s[i] == 'r')
a++;
if(s[i] == 'b')
b++;
}
else
{
if(s[i] == 'r')
c++;
if(s[i] == 'b')
d++;
}
}

ans = min(max(b,c),max(a,d));

cout << ans;

return 0;
}
本站文章除注明转载外均为原创,未经允许不要转载哇. ヾ(゚ー゚ヾ) http://chicago01.top/2019/05/13/cf719b-anatoly-and-cockroaches/index.html
Compartir