vahdat-city's blog

By vahdat-city, 10 years ago, In Russian

http://codeforces.net/contest/522/problem/C

include<bits/stdc++.h>

using namespace std;

long long a[100001];

int main()

{

long long min1=1000000,q=1,t,n,m,l,r,k=0,i,j,g,z;

cin>>t;

for(i=1;i<=t;i++)

{

    cin>>m>>n;
     min1=1000000;
    for(j=1;j<=n;j++)

        cin>>a[j];

        q=1;

        k=0;

    for(j=1;j<=m-1;j++)

    {

        cin>>l>>r;

        if(l==0)

        {

            k++;

        }

        else

        if(l!=0)

        {

            a[l]--;

        }

         if((r==1)&&(q==1))

        {

            q=0;

             for(g=1;g<=n;g++)

            {

                if((min1>a[g])&&(g!=l))

                {

                    min1=a[g];
                }

            }

            for(g=1;g<=n;g++)

            {

                if((a[g]==min1)&&(g!=l))

                    a[g]=0;

            }

            k-=min1;

        }

    }

    for(j=1;j<=n;j++)

    {

        if(a[j]>k)

        {

            cout<<'N';

        }

        else

        cout<<'Y';

    }

    cout<<endl;

}

}

  • Vote: I like it
  • -22
  • Vote: I do not like it