1092 To Buy or Not to Buy (20 分)

水题~。

注意:商店每串珠子都不拆开售卖,只能整串购买。

map<char,int> mpa,mpb;
string a,b;

int main()
{
    cin>>a>>b;
    for(auto t:a) mpa[t]++;
    for(auto t:b) mpb[t]++;

    int buy=0,miss=0;
    for(auto t:mpb)
    {
        if(t.se > mpa[t.fi])
            miss+=t.se-mpa[t.fi];
    }

    if(!miss) cout<<"Yes"<<' '<<a.size()-b.size()<<endl;
    else cout<<"No"<<' '<<miss<<endl;

    //system("pause");
    return 0;
}
posted @ 2021-02-17 18:58  Dazzling!  阅读(46)  评论(0编辑  收藏  举报