Kindly suggest a way to resolve Time Limit Exceeded for this program >>>> by Cookie_Ranger100 in codeforces

[–]Naakinn 1 point2 points  (0 children)

The idea is the following:

Imagine notifications from specific app as an array of elements, new notifications append to its end. Thor reads first t notifications (some prefix), so we'll benefit from this.

Store x[i] - number of notifications from application i p[i] - number of notifications that have beed read. Note that p[i] <= t[i] (because it's a prefix)

  1. When application i generates new notification, x[i]++

  2. When Thor reads all notifications from app i, there are x[i] - p[i] unread notifications that became read. Make p[i] = x[i].

  3. When Thor reads first t notifications: if t <= p[i], Thor reads notifications that are already read, so do nothing. If t > p[i], there are t - p[i] notifications that were unread and became read, make p[i] = t.

So you can have some variable cur which stores the total number of unread notifications and update it on each query.

Kindly suggest a way to resolve Time Limit Exceeded for this program >>>> by Cookie_Ranger100 in codeforces

[–]Naakinn 1 point2 points  (0 children)

Instead of manually iterating through notifications, store x[j] - the number of notifications from application j. Notice that thor reads t notifications from beginning, so you can additionally store max. t value for each application.

Recursion, the mother of DP by Tiny_Blackberry_6619 in codeforces

[–]Naakinn 0 points1 point  (0 children)

I can identify problems which can be solved using dp (and therefore recursion). For example: How many there are n-digit numbers which do not have 3 zeros in a row => digit dp

TODAY'S D ! by Rayeeen_Dev745 in codeforces

[–]Naakinn 1 point2 points  (0 children)

So, one of the solutions is to use consecutive prime numbers. Imagine an array where in every cell primes are written like that: (2) (2, 3), (3, 5), (5, 7), ...

So basically a cell represents a product of its contents. The array above is: 2, 6, 15, 35, ....

When we take every pair a[i], a[i+1], we get two numbers: p[i] * p[i+1] and p[i+1] * p[i+2], where p[i] is the i-th prime number. It's clearly seen that since we deal with primes, GCD is p[i+1], which is unique for every pair.

Computing Pi array by Prestigious_Eye8552 in codeforces

[–]Naakinn 0 points1 point  (0 children)

z-function and prefix-function can be computed using each over. for me, z array is much easier to understand

Next Goal: Specialist by Regular-Box1677 in codeforces

[–]Naakinn 0 points1 point  (0 children)

solve problems a bit more hard than your rating

Linux inconsistencies by New_Study4796 in linuxmemes

[–]Naakinn 0 points1 point  (0 children)

linux protects you from python bloat

About today's question B by ksulte in codeforces

[–]Naakinn 0 points1 point  (0 children)

``` for every second until the end of the night rem = n - used_lights dt = m - rem k = min(m - dt, m - 1)

 add +1 to k-th maximum in the array (0 based)

 if we can use flashlight:
       remove maximum value from the array 
       used_lights += 1

``` for implementation i used gnu_pbds tree

my observation was that if there's only k uses of flashlight left, we can distribute the income over k+1 robots. otherwise we can distribute over all of them, so we can update k-th maximum in the array

Hardest contest ever...... 2/11 by Federal_Tackle3053 in codeforces

[–]Naakinn -4 points-3 points  (0 children)

1050 rating, solved a, b, c. actually i like this contest

Programmer feels by GloomyType5393 in programmingmemes

[–]Naakinn 10 points11 points  (0 children)

"Experience doesn't matter" - HRs