Min no of +1 operations on array to have only k distinct elements

Before contest

Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)

08:08:53

Register now »

Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)

08:08:53

Register now »

*has extra registration

# | User | Rating |
---|---|---|

1 | tourist | 3682 |

2 | ecnerwala | 3603 |

3 | Benq | 3549 |

4 | Radewoosh | 3494 |

5 | Petr | 3452 |

6 | ksun48 | 3413 |

7 | maroonrk | 3406 |

8 | Miracle03 | 3314 |

9 | scott_wu | 3313 |

10 | Um_nik | 3299 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 214 |

2 | Errichto | 188 |

3 | awoo | 187 |

4 | rng_58 | 186 |

5 | SecondThread | 183 |

6 | Ashishgup | 176 |

6 | Um_nik | 176 |

8 | maroonrk | 173 |

9 | antontrygubO_o | 171 |

10 | -is-this-fft- | 169 |

Min no of +1 operations on array to have only k distinct elements

The ememy of your ememy is friend.Given Q queries of form:

1 person1 person2

2 0 person

person is signified using id

your id is 0

for query of type 2 print following:

-1 if person is your enemy

1 if person is your friend

0 if person is not related to you

A person is your friend if he is:

enemy of your enemy

enemy of your's friend enemy and so on

constraints : 0<id<10^5 0<Q<10^5

example:

1 1 2

1 0 1

1 3 4

2 0 1

2 0 2

2 0 4

output:

-1

1

0

Given two binary strings of equal length (eg. "10101" and "10010") we had to find whether we can convert string 1 to string 2 by performing following operations:

reverse substring of length 2 reverse substring of length 2 reverse substring of length 2

Given a range [l r] find the sum of last digits of fibonacci numbers between l and r. i.e , last(fib(l))+last(fib(l+1)) .... last(fib(r)),

where last(fib(a)) denotes last digit of ath fibonacci number.

1<=l<=r<=1e9

Given an array, choose two contiguous non-overlapping arrays, such that all elements are strictly increasing. Return the maximum length possible for this combination.

Ex: 7 1 2 4 6 5 3 8 9 10 => ans: 7 (Choose 1 2 4 6 & 8 9 10)

given a number n, convert it into k such that k has all even digit with minimum no of operations. 1 operation is either increment or decrement n by 1.

example: Input 11 output -> 3 Input 199 output -> 1 Input 2018 output -> 2

You are working in Samara, Russia for a few days. Each day has a new pay per unit of work and a new cost per unit of food. Working 1 unit costs 1 unit of energy, and eating 1 unit of food adds 1 unit of energy. Here are some specifications of your employment:

You arrive with no money, but with energy. You can never have more energy than you arrive with, and it can never be negative. You can do any amount of work every day (possibly not do any work at all), limited only by your energy. You cannot work when your energy is zero. You can eat any amount of food every day (possibly not have any food at all), limited by the money you have. You cannot eat when the money you have is zero. You can eat food at the end of the day, and cannot return to work after eating. You can return to work the next day. Your true goal is to return home with as much money as possible. Compute the maximum amount of money you can take home.

Input: N = 3, Earning=[1, 2, 4], Cost[]=[1, 3, 6], E = 5 Output: 20

How to count total no. of distinct cycles in an undirected graph. Graph may be disconnected. Constraints: 0<= no. of nodes <=10

Answer for given image is 7

You Are given an array **A** of **N** integers. You have to answer **Q** queries of form **L R**. Answer to each query is sum of lengths of all sub arrays in **A** whose maximum element lies in range [L,R].

**Constraints:**

1<=N,Q<=3*10^5 1<=A[i]<=10^9 1<=L<=R<=10^9

**Input:** ` 5 3 `

` 1 2 3 4 5 `

` 1 3 `

` 1 5 `

` 5 5 `

**Output:**

10 35 15

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/23/2021 09:26:08 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|