HCPC2014校赛训练赛 4 A.Alphabet Cookies (3.16)

A.Alphabet Cookies
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 118 (62 users) Total Accepted: 74 (58 users) Special Judge: No
Description

Kitty likes cookies very much, and especially the alphabet cookies. Now, she get some alphabet cookies, and she wants to select some of them to spell some words.

The easy task for you, is to determine that whether she can spell the word she wants.

Input

The input contains several test cases.

Each test case contains an integer N ( 0 < N  100 ) in a line.

And followed a line with N capital letters, means the cookies she has.

Then the last line is a word with capital letters. And the word’s length isn’t more than N.

Output


    One word for each test case. If she can spell the word by these letters, please output “Yes”, nor output “No”.

Sample Input

7

ARDHPYP

HAPPY

6

ARDHPY

HAPPY

Sample Output

Yes

No

Author
BH


#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    string a,b;int n,i;
    while(cin>>n)
    {
        int x[26],y=0;
        memset(x,0,sizeof(x));
        cin>>a;
        for(i=0;i<n;i++)x[a[i]-'A']++;
       // for(i=0;i<26;i++) cout<<x[i]<<" ";
        cin>>b;
        for(i=0;i<b.length();i++)
        {
            x[b[i]-'A']--;
            if(x[b[i]-'A']<0)
            {
                y=1;
                break;
            }
        }
           if(y==0)  cout<<"Yes"<<endl;
           else cout<<"No"<<endl;
    }
    return 0;
}

结果:
78099 A Accepted G++ 1ms 1144k 611B 2014-03-16 13:37:45

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值