abc046d
https://atcoder.jp/contests/abc046/tasks/arc062_b
// https://atcoder.jp/contests/abc046/tasks/arc062_b
// 策略 : 与对方做出相同的动作, 至少能保证得分>=0
// 如对方的布的次数没有达到使用上限, 则我就可以用剩余的布的次数去赢对方的石头
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
void solv()
{
string s;
cin >> s;
int n = s.length();
int ng = 0;
for (int i = 0; i < n; i ++) if (s[i] == 'g') ng ++;
int np = n - ng;
int maxp = n / 2;
int rem = maxp - np;
cout << rem << endl;
// cout << np << ' ' << ng << endl;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
{
solv();
}
return 0;
}
本文来自博客园,作者:O2iginal,转载请注明原文链接:https://www.cnblogs.com/o2iginal/p/17493040.html