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
cake_is_a_lie: 2022-05-16 14:50:02

Read the limits carefully; that's a 2e5 for N, M; I got SIGSEGVs because I assumed it was 1e5.
Other than that, the problem description seems to be inaccurate. The task seems to be to match each virus to the first site it can attack.

Simes: 2022-02-11 20:14:29

So it sounds like this bit isn't correct either then... "your goal is to deal damage to as many Sites as possible, rather totally destroying a site". If a virus attacks the site with the lowest index, rather than a site that hasn't yet been attacked at all.

codingjedi048: 2022-02-11 13:44:54

I'm extremely sorry for the inconvenience.
The virus will start attacking from the site which has the minimum index. This was correctly observed by @Blue Mary and also have already been given in the Problem Statement.

Vipul Srivastava: 2022-02-03 18:12:04

I agree with @nadstratosfer.

nadstratosfer: 2022-02-03 02:19:58

Why was Zukow's comment deleted?
---

"You have to do the mapping in such a way that, the number of spam mails that have been sent is maximized."
I find this sentence misleading. As Blue Mary already explained: every virus attacks site with minimum index it can successfully attack (considering effects of viruses before it). It doesn't have to to maximize the total number spam mails.

:D: 2022-01-26 01:20:34

"You have to do the mapping in such a way that, the number of spam mails that have been sent is maximized."
I find this sentence misleading. As Blue Mary already explained: every virus attacks site with minimum index it can successfully attack (considering effects of viruses before it). It doesn't have to to maximize the total number spam mails.

codingjedi048: 2022-01-10 22:15:48

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...

It's already given in the problem Statement. Don't miss that.

Vipul Srivastava: 2022-01-10 15:03:12

Thanks

[Rampage] Blue.Mary: 2022-01-10 14:09:24

The sample output matches the output of my program.

Vipul Srivastava: 2022-01-10 13:30:06

@Blue Mary thanks.

Last edit: 2022-01-10 14:09:17

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