Jinixin Speech

Time Limit: 1 Sec Memory Limit: 128 MB

Description

As we all know, Jinixin has a very famous speech - "Keep some distance from me".

Jinixin is so rich that everyone want to contact him, and Mosu is one of them. One

day , Jinixin agreed with Mosu to contact him if Mosu could beat him. There are n

digits(lets give them indices from 1 to n and name them a1,a2...an) and some queries.

For each query:

1.Jinixin choose an index x from 1 to n.

2.For all indices y ( y < x) calculate the difference by=ax−ay.

3.Then Jinixin calculate B1 the sum of all by which are greater than 0 , and

Mosu calculate B2 , the sum of all by which are less than 0.

if B1>|B2| , Jinixin won and did not agree with Mosu to contact him; else if B1 is

equals to |B2| , Jinixin would ignore the result; else if B1< |B2| , Jinixin lost and

agreed with Mosu to contact him.

Input

The first line contains two integers n, m (1≤n,m≤100000) denoting the number

of digits and number of queries. The second line contains n digits (without spaces)

a1,a2,...,an.(0≤ai≤9) Each of next m lines contains single integer x (1≤x≤n)

denoting the index for current query.

Output

For each of m queries print "Keep some distance from me" if Jinixin won, else

print "Next time" if Jinixin ignored the result, else print "I agree" if Jinixin lost in a line -

answer of the query.

Sample Input

10 3

0324152397

1

4

7

Sample Output

Next time

Keep some distance from me

I agree

 

#include<stdio.h>
#include<string.h>
int main()
{
    char a[100001];
    long long m,n,i,j,x,b[100001];
    long long sum;
    while(scanf("%lld%lld",&n,&m)!=EOF)
    { memset(b,0,sizeof(b));
        sum=0;
        scanf("%s",&a);
        for(j=0; j<n; j++)
        {
            b[j+1]=(a[j]-'0'+0)*j-sum;
            sum=sum+(a[j]-'0'+0);
        }
        while(m--)
        {
            scanf("%lld",&x);
            if(b[x]>0)
            {
                printf("Keep some distance from me\n");
            }
            else if(b[x]==0)
            {
                printf("Next time\n");
            }
            else
            {
                printf("I agree\n");
            }
        }
    }
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值