CF 518B (Tanya and Postcard-counting statistics)

Source: Internet
Author: User

CF 518B (Tanya and Postcard-counting statistics)

B. Tanya and Postcardtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message-stringSOf lengthN, Consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve stringS. The newspaper contains stringT, Consisting of uppercase and lowercase English letters. We know that the length of stringTGreater or equal to the length of the stringS.

The newspaper may possibly have too few of some letters needed to make the text and too versions of some other letters. That's why Tanya wants to cut someNLetters out of the newspaper and make a message of length exactlyN, So that it looked as much as possible likeS. If the letter in some position has correct value and correct letter case (in the stringSAnd in the string that Tanya will make), then she shouts joyfully "YAY! ", And if the letter in the given position has only the correct value but it is in the wrong case, then the girl says" WHOOPS ".

Tanya wants to make such message that lets her shout "YAY! "As much as possible. if there are multiple ways to do this, then her second priority is to maximize the number of times she says "WHOOPS ". your task is to help Tanya make the message.

Input

The first line contains lineS(1? ≤? |S|? ≤? 2. 105), consisting of uppercase and lowercase English letters-the text of Tanya's message.

The second line contains lineT(|S|? ≤? |T|? ≤? 2. 105), consisting of uppercase and lowercase English letters-the text written in the newspaper.

Here |A| Means the length of the stringA.

Output

Print two integers separated by a space:

  • The first number is the number of times Tanya shouts "YAY! "While making the message,
  • The second number is the number of times Tanya says "WHOOPS" while making the message. Sample test (s) input
    AbCDCbA
    Output
    3 0
    Input
    ABCabc
    Output
    0 3
    Input
    abacabaAbaCaBA
    Output
    3 4

    Count the number of each letter, greedy



    #include
       
        #include
        
         #include
         
          #include#include
          
           #include
           
            #include
            
             #include
             
              #include
              
               using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i
               
                =0;i--)#define Forp(x) for(int p=pre[x];p;p=next[p])#define Forpiter(x) for(int &p=iter[x];p;p=next[p]) #define Lson (x<<1)#define Rson ((x<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (100000007)#define MAXN (2000000)long long mul(long long a,long long b){return (a*b)%F;}long long add(long long a,long long b){return (a+b)%F;}long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}typedef long long ll;char s[MAXN],t[MAXN];int f[MAXN]={0};int main(){freopen("Invitation.in","r",stdin);//freopen(".out","w",stdout);scanf("%s%s",s,t);int n1=strlen(s),n2=strlen(t);Rep(i,n2) f[t[i]]++;int p=0;Rep(i,n1){if (f[s[i]]>0) f[s[i]]--,p++,s[i]=0;}cout<
                
                 




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.