100735G

很明显,我们构造出一个串后,无非就是两个结果:最长的是黑的,最长的是白的,因此选两个中小的就可以了

#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int tot1=0,tot2=0;
    for(int i=0;i<s.length();i++)
    {
        tot1+=s[i]==‘0‘;
        tot2+=s[i]==‘1‘;
    }
    cout<<min(tot1,tot2)<<endl;
    return 0;
}
时间: 2024-10-24 01:46:39

100735G的相关文章

CodeForcesGym 100735G LCS Revised

LCS Revised Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on CodeForcesGym. Original ID: 100735G64-bit integer IO format: %I64d      Java class name: (Any) The longest common subsequence is a well known DP problem: given two st