# PROBLEM LINK:

Contest - Division 3

Contest - Division 2

Contest - Division 1

Setter: Arshdeep Singh

Tester: Vichitr Gandas, Anshu Garg

# DIFFICULTY:

SIMPLE

# PROBLEM:

Given an array S of size N. Determine if it is possible to add integer K (may be negative) to S_N at most L-1 times, such that S_N is then greater than all other elements in S.

# EXPLANATION:

If K < 0, injecting the drug will reduce his speed; so it’s better to not inject the drug at all. In this case, your friend wins only if he is faster than everyone else \implies S_N > S_i should hold for all valid i < N.

If K > 0, we can repeatedly inject the drug until the limit is reached (that is, we can inject the drug L-1 times), increasing his speed in each dose. If after this, your friend is faster than everyone else, he wins \implies S_N+K*(L-1) > S_i should hold for all valid i < N.

# TIME COMPLEXITY:

Since we iterate over array S once to determine the answer, the time complexity for each test case is:

# 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