VACCINQ - Editorial

PROBLEM LINK:

Contest - Division 3
Contest - Division 2
Contest - Division 1

DIFFICULTY:

CAKEWALK

PROBLEM:

Chef is standing for the vaccine in a queue, at the P^{th} position from the front of the line. Given the status of all people in the queue (child/elderly person), and that it takes X and Y minutes to vaccinate a child and elder, respectively.

Determine the number of minutes until Chef finishes getting his vaccination.

EXPLANATION:

Since Chef is vaccinated only after the P-1 people in front of him are vaccinated, the total time for the completion of Chef’s vaccination is equal to the time it takes to vaccinate the first P people in the queue.

Therefore, for each person i\space(1\le i\le P) from the front of the queue, add the time it takes to vaccinate him/her (X for a child, Y for an adult) to get the final answer.

TIME COMPLEXITY:

Since we iterate over the first P people in the queue (adding their vaccination time to the answer), the time complexity is

O(P)

per test case.

SOLUTIONS:

Editorialist’s solution can be found here.


Experimental: For evaluation purposes, please rate the editorial (1 being poor and 5 excellent)

  • 1
  • 2
  • 3
  • 4
  • 5

0 voters