CodeForces 43B Letter

B. Letter
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces out of the heading — he just leaves some blank space to mark them. Help him; find out if he will manage to compose the needed text.

Input

The first line contains a newspaper heading s1. The second line contains the letter text s2. s1 и s2 are non-empty lines consisting of spaces, uppercase and lowercase Latin letters, whose lengths do not exceed 200 symbols. The uppercase and lowercase letters should be differentiated. Vasya does not cut spaces out of the heading.

Output

If Vasya can write the given anonymous letter, print YES, otherwise print NO

Sample test(s)
Input
Instead of dogging Your footsteps it disappears but you dont notice anything
where is your dog
Output
NO
Input
Instead of dogging Your footsteps it disappears but you dont notice anything
Your dog is upstears
Output
YES
Input
Instead of dogging your footsteps it disappears but you dont notice anything
Your dog is upstears
Output
NO
Input
abcdefg hijk
k j i h g f e d c b a
Output
YES

#include<cstring>
#include<iostream>
using namespace std;

int main(){
    int len1,len2,t,flag,num[70];
    string s1,s2;
    getline(cin,s1);
    getline(cin,s2);
    memset(num,0,sizeof(num));
    flag=1;
    len1=s1.size();
    len2=s2.size();
    for(int i=0;i<len1;i++){
        t=s1[i]-'A';
        num[t]++;
    }
    for(int i=0;i<len2;i++){
        t=s2[i]-'A';
        num[t]--;
        if(num[t]<0){
            flag=0;
            break;
        }
    }
    if(flag){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值