After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.

Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick.

Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks.

Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of digits in the cards Sherlock and Moriarty are going to use.

The second line contains n digits — Sherlock's credit card number.

The third line contains n digits — Moriarty's credit card number.

Output

First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty.

Examples
input

Copy
3
123
321
output

Copy
0
2
input

Copy
2
88
00
output

Copy
2
0
Note

First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.


刚开始以为是说田忌赛马福尔摩斯版,实际上有一点不一样,读题很重要。

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = 1e5 + ;
const long long inf = 0x7f7f7f7f7f7f7f7f; int main()
{
int n, sf = , mf = ;
cin >> n;
string s, m;
cin >> s;
cin >> m;
vector<int> sn, mn;
for (int i = ; i < s.size(); i++)
{
sn.push_back(s[i] - '');
mn.push_back(m[i] - '');
}
sort(mn.begin(), mn.end());
for (int i = ; i < s.size(); i++)
{
vector<int>::iterator iter;
iter = lower_bound(mn.begin(), mn.end(), sn[i]);
if (iter == mn.end())
{
sf++;
}
else
mn.erase(iter);
}
mn.clear();
for (int i = ; i < s.size(); i++)
{
mn.push_back(m[i] - '');
}
sort(mn.begin(), mn.end());
for (int i = ; i < s.size(); i++)
{
vector<int>::iterator iter;
iter = upper_bound(mn.begin(), mn.end(), sn[i]);
if (iter != mn.end())
{
mn.erase(iter);
mf++;
}
}
cout << sf << endl;
cout << mf << endl;
return ;
}

Game of Credit Cards的更多相关文章

  1. code force 401B. Game of Credit Cards

    B. Game of Credit Cards time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. Codeforces 777B Game of Credit Cards

    B. Game of Credit Cards time limit per test:2 seconds memory limit per test:256 megabytes input:stan ...

  3. Codeforces777B Game of Credit Cards 2017-05-04 17:19 29人阅读 评论(0) 收藏

    B. Game of Credit Cards time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. Game of Credit Cards(贪心+思维)

    After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle betwe ...

  5. Codeforces 777B:Game of Credit Cards(贪心)

    After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle betwe ...

  6. CodeForces - 777B Game of Credit Cards 贪心

    题目链接: http://codeforces.com/problemset/problem/777/B 题目大意: A, B玩游戏,每人一串数字,数字不大于1000,要求每人从第一位开始报出数字,并 ...

  7. 【贪心】【multiset】 Codeforces Round #401 (Div. 2) B. Game of Credit Cards

    对第一个人的排序,然后从小到大处理,对第一个人的每枚卡片,从第二个人的卡片中选择一个大于等于它的最小的,否则选择一个当前剩下的最小的,这样可以保证负场最少. 如果选择的改成大于它的最小的,就可以保证胜 ...

  8. 【codeforces 777B】Game of Credit Cards

    [题目链接]:http://codeforces.com/contest/777/problem/B [题意] 等价题意: 两个人都有n个数字, 然后两个人的数字进行比较; 数字小的那个人得到一个嘲讽 ...

  9. Emotion Debt 2017/1/6

    原文 We can't move beyond the past until our emotional debts are paid. Many people today live under th ...

随机推荐

  1. 使用Office365账号配置SMTP中继服务器

    · 如何将企业中的多功能设备(打印机.扫描仪等 )或应用程序设置为使用 Office 365 发送电子邮件,微软给出了3种方法: SMTP 客户端提交 直接发送 SMTP 中继 以上3种方式的介绍,大 ...

  2. 题解 AT4278 【[ABC115A] Christmas Eve Eve Eve】

    题目传送门. 分析 根据题目,我们可以发现要求如下: \(d\)的值 输出 \(d=25\) Christmas \(d=24\) Christmas Eve \(d=23\) Christmas E ...

  3. Python类的特殊成员方法

    __doc__ 类的描述信息. class dog: '''这是狗的类''' def __init__(self,name): self.name = name self.__age = None p ...

  4. C# WPF过渡效果实现(C# WPF Material Design UI: Transitions)

    时间如流水,只能流去不流回! 点赞再看,养成习惯,这是您给我创作的动力! 本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform.W ...

  5. 移动端 h5

    取消点击时候的透明区域 -webkit-tap-highlight-color: rgba(0,0,0,0); iphonex 适配 <meta name="viewport" ...

  6. python开发第二篇 :python基础

    python基础a.Python基础      -基础1. 第一句python       -python后缀名可以任意?     -导入模块时如果不是.py文件,以后的文件后缀名是.py.2.两种 ...

  7. Networking POJ - 1287 最小生成树板子题

    #include<iostream> #include<algorithm> using namespace std; const int N=1e5; struct edge ...

  8. c++ STL queue:deque+优先队列

    /* queue 模板类需要两个模板参数,一个是元素类型,一个容器类型,元素类型是必要的,容器类型是可选的,默认为deque队列   类型.一:定义queue(要有头文件#include <qu ...

  9. 数据预处理 | 使用 Pandas 进行数值型数据的 标准化 归一化 离散化 二值化

    1 标准化 & 归一化 导包和数据 import numpy as np from sklearn import preprocessing data = np.loadtxt('data.t ...

  10. Linux下用Bash语言实现输出水仙花数的功能

    题目链接: 题目描述 打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身. 例如:153是一个水仙花数,因为153=1^3+5^ ...