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

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

1 | tourist | 3778 |

2 | Benq | 3592 |

3 | ecnerwala | 3521 |

4 | Um_nik | 3423 |

5 | jiangly | 3375 |

6 | Petr | 3342 |

7 | Radewoosh | 3337 |

8 | scott_wu | 3313 |

9 | maroonrk | 3265 |

10 | yosupo | 3259 |

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

1 | Errichto | 202 |

2 | 1-gon | 201 |

3 | rng_58 | 194 |

4 | SecondThread | 193 |

5 | awoo | 187 |

6 | vovuh | 183 |

7 | Um_nik | 182 |

8 | antontrygubO_o | 177 |

9 | Ashishgup | 175 |

10 | -is-this-fft- | 171 |

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: Jan/17/2021 06:18:53 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|