시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 66 | 59 | 46 | 93.878% |
Your social media account has just been hacked, and you are advised to change your password. You have two favorite strings S and T, each contains exactly N lowercase alphabets. You want the new password to be some combinations of these two strings. Specifically, the new password P should contain N alphabets such that the ith character of P is either the ith character of S or the ith character of T.
For example, let S = “icyz
” and T = “ixpc
”. There are 8 different possible new passwords which you can choose: “icyz
”, “icyc
”, “icpz
”, “icpc
”, “ixyz
”, “ixyc
”, “ixpz
”, and “ixpc
”.
The score of a password P is defined as the number of occurences of the most frequent alphabet in P. For example, let P = “icpc
”. The password “icpc
” has one occurence of ‘i
’, two occurences of ‘c
’, and one occurence of ‘p
’. The most frequent alphabet in P is ‘c
’ with the number of occurences of 2. Therefore, the score of “icpc
” is 2.
Given two strings S and T, your task is to find the highest score you can get for your new password.
Input begins with a line containing an integer: N (1 ≤ N ≤ 100 000) representing the length of the password. The next line contains a string S containing N lowercase alphabets representing your first favorite string. The next line contains a string T containing N lowercase alphabets representing your second favorite string.
Output in a line an integer representing the highest score you can get for your new password.
4 icyz ixpc
2
These two strings are given as an illustration in the problem description as well as all its possible new passwords. Among them, the passwords “icyc
” and “icpc
” have the highest score of 2, while the other remaining passwords have a score of 1.
11 goodluckfor contestants
3
14 helpiamtrapped inanincfactory
4
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2019 I번
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2021 PA번