SPAM_ATX - Internet Spamming

no tags 

Two Years from now,
Spam will be solved.
Bill Gates (2004)

Let’s imagine...

The World has evolved so much. Nowadays, the anger of rivalries is being extinguished by the help of internet. You’re the Mr. Despicable of the underworld and you have invented a new cyber virus, which acts like a SPAM.

As people are getting more and more virtual, the count of Social sites are being raised on the peak rate. You want to deal damage to some Social Sites. Remember, “Suffering is more painful than Death”. So, your goal is to deal damage to as many sites as possible, rather than totally destroying a site.

Each of the viruses will send some spam mails. If a user receives a Spam, the account of the user will be removed forever from the site that the user is using and the site will lose one of its users.

Now, being a Programmer, you know a virus is nothing but a set of instructions. You have coded everything a virus has to follow except one thing, “On which site a certain virus should attack?” Now, you have to write a program that will tell each virus on which site it should attack. There is also a bug on your viruses. A virus cannot attack a site, unless the count of users on that site is more than or equal to the count of spams the virus can produce. Moreover, the viruses will start attacking maintaining the order in which they are given in the input. The first virus will start sending Spams first, then the second one, and so on...

Now, write a program that will tell a virus, on which site it should attack.

Input

Line 1: N (<= 2e5), M (<= 2e5) [Number of Sites and Number of Viruses]

Line 2: U1, U2, U3, ... Un (Ui<=1e9) [Number of Users on the ith site]

Line 3: P1, P2, P3, ... Pm (Pi<=1e9) [Number of spam mails the ith virus can produce]

Output

Line 1: I1, I2, I3, ... Im (1<=Ii<=N) [Index of the Site the ith virus should attack on]

Note: If there are no sites, the ith virus can attack, print 0 on the ith index.

Sample

Input:
10 10
7 2 9 5 1 2 1 1 2 5
7 5 6 4 8 3 9 10 1 6

Output:
1 3 0 3 0 4 0 0 2 0

Explanation

1st virus attacked the 1st site, after that the users of the 1st site decreased to 0. Now, no virus can attack the 1st site.

2nd virus attacked the 3rd site, and then the users of the 3rd site decreased to 4 and later on, it was attacked again by the 4th site and got users count decreased to 0.

Now, there remains no sites, which has users more than or equal to the spam mails of the 3rd virus. That’s why, it can attack no site.


hide comments
[Rampage] Blue.Mary: 2022-01-10 12:48:37

My AC program assumes the virus will attack the first site (minimum index) it can successfully attack.

Vipul Srivastava: 2022-01-09 18:17:54

@author my algorithm manages to attack 6 sites which is greater than 5 based on the sample i/o

my output - 1 4 3 10 0 3 0 0 5 0
Shouldn't this be the correct answer?

so I have attacked 5 distinct websites and in the sample output its only 4 distinct websites.

Last edit: 2022-01-09 18:22:18

Added by:Dr. AddictStein
Date:2022-01-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Dr. AddictStein Research Lab