Educational Codeforces Round 63 (Rated for Div. 2) Game with Telephone Numbers B

A telephone number is a sequence of exactly 11

digits such that its first digit is 8.

Vasya and Petya are playing a game. Initially they have a string s

of length n (n is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and erase it from the current string. For example, if the current string 1121, after the player's move it may be 112, 111 or 121. The game ends when the length of string s

becomes 11. If the resulting string is a telephone number, Vasya wins, otherwise Petya wins.

You have to determine if Vasya has a winning strategy (that is, if Vasya can win the game no matter which characters Petya chooses during his moves).

Input

The first line contains one integer n

(13≤n<105, n is odd) — the length of string s

.

The second line contains the string s

(|s|=n

) consisting only of decimal digits.

Output

If Vasya has a strategy that guarantees him victory, print YES.

Otherwise print NO.

Examples

Input

Copy

13
8380011223344

Output

Copy

YES

Input

Copy

15
807345619350641

Output

Copy

NO

Note

In the first example Vasya needs to erase the second character. Then Petya cannot erase a character from the remaining string 880011223344 so that it does not become a telephone number.

In the second example after Vasya's turn Petya can erase one character character 8. The resulting string can't be a telephone number, because there is no digit 8 at all.

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;
char a[320000];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%s",a+1);
        int sum=0;
        for(int i=1;i<=n-10;i++)
        {
            if(a[i]=='8') sum++;
        }
        int m;
        m=(n-11)/2+1;
        if(sum>=m)
        {
            printf("YES\n");
        }
        else printf("NO\n");
    }
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值