Блог пользователя AshnuB

Автор AshnuB, 4 месяца назад, По-английски

Q1) You are given four integer arrays task1, task2, task3, and task4, each of length n.

task1[i], task2[i], task3[i], task4[i] represent the points gained if you choose task type 1, 2, 3, or 4 respectively at index i.

Each index i represents a task bundle.

From each index i, you must choose exactly one task type:

task1, task2, task3, or task4

Each index is used exactly once (no skipping).

Your selection must satisfy the following global constraints:

At least k tasks are chosen from task1 At most k tasks are chosen from task2 The number of tasks chosen from task3 is not equal to k Exactly k tasks are chosen from task4 Maximize the total points, defined as the sum of the selected task values across all indices.

Example 1:

Input:

task1 = [5, 4, 6, 3, 7, 2], task2 = [2, 3, 1, 4, 2, 1], task3 = [4, 2, 5, 1, 3, 4], task4 = [3, 4, 2, 5, 1, 2] , k = 2

Output: 31

Explaination:

One valid assignment is:

Choose task1 at indices 0, 2, 4 Choose task3 at index 5 Choose task4 at indices 1, 3 Counts:

task1 = 3 >= 2 task2 = 0 <= 2 task3 = 1 != 2 task4 = 2 == 2 Total points = 5 + 6 + 7 + 4 + 4 + 5 = 31

Example 2:

Input:

task1 = [1, 1, 1, 1, 1, 1], task2 = [2, 2, 2, 2, 2, 2], task3 = [0, 0, 0, 0, 0, 0], task4 = [1, 1, 1, 1, 1, 1], k = 2

Output: 8

Explanation:

One valid assignment is:

task1 at indices 4, 5 task2 at indices 0, 1 task4 at indices 2, 3 Counts:

task1 = 2 >= 2 task2 = 2 <= 2 task3 = 0 != 2 task4 = 2 == 2 Total Points = 1 + 1 + 2 + 2 + 1 + 1 = 8

Constraints:

1 <= task1.length == task2.length == task3.length == task4.length <= 10^5 1 <= task1[i] , task2[i] , task3[i] , task4[i] <= 10^9 0 <= k <= n

Q2)You are given a string s, Return the number of super substrings.

Substring is said to be super if number of 'A' is strictly greater than number of 'B' is strictly greater than number if 'C' ('A'>'B'>'C') or number of 'A' is strictly lesser than number of 'B'is strictly lesser than number of 'C' ('A'<'B'<'C')

Example 1:

Input: s = "AAAABBC"

Output: 7

Explaination:

Valid Super Substrings follows count('A') > count('B') > count('C'):

s[0..4] => 'A' = 4, 'B' = 1, 'C' = 0 s[0..5] => 'A' = 4, 'B' = 2, 'C' = 0 s[0..6] => 'A' = 4, 'B' = 2, 'C' = 1 s[1..4] => 'A' = 3, 'B' = 1, 'C' = 0 s[1..5] => 'A' = 3, 'B' = 2, 'C' = 0 s[1..6] => 'A' = 3, 'B' = 2, 'C' = 1 s[2..4] => 'A' = 2, 'B' = 1, 'C' = 0

Example 2:

Input: s = "ACBACBA"

Output: 0

Explaination:

Since there is no substrings follows the condition return 0

Example 3:

Input: s = "CCCCBBA"

Output: 7

Explaination:

Valid Super Substrings follows count('A') < count('B') < count('C'):

s[0..4] => 'A' = 0, 'B' = 1, 'C' = 4 s[0..5] => 'A' = 0, 'B' = 2, 'C' = 4 s[0..6] => 'A' = 1, 'B' = 2, 'C' = 4 s[1..4] => 'A' = 0, 'B' = 1, 'C' = 3 s[1..5] => 'A' = 0, 'B' = 2, 'C' = 3 s[1..6] => 'A' = 1, 'B' = 2, 'C' = 3 s[2..4] => 'A' = 0, 'B' = 1, 'C' = 2

Example 4:

Input: s = "AAAABBCCCCBBA"

Output: 27

Explaination:

There are 27 Possible Super Substrings and follows both count('A') < count('B') < count('C') andcount('A') > count('B') > count('C').

Constraints:

1 <= s.length <= 8 * 10^4 s consists only of characters 'A' ,'B' and 'C'.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор AshnuB, история, 9 месяцев назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in Greedy Algorithms contest, which will be held at Sunday, September 14, 2025 at 14:20 UTC+5.5. You will be given 7 problems and 7 hours to solve them.

Plz Join this link.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

Автор AshnuB, 11 месяцев назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in Atcoder Beginner Like Round- 002, which will be held at Saturday, July 12, 2025 at 16:30 UTC+5.5. You will be given 7 problems and 1 hour and 40 minutes to solve them.

Plz Join this link.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор AshnuB, история, 11 месяцев назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in Atcoder Beginner Like Round- 001, which will be held at Saturday, July 05, 2025 at 17:45 UTC+5.5. You will be given 7 problems and 1 hour and 40 minutes to solve them.

Plz Join this link.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор AshnuB, история, 22 месяца назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in ICPC Beginner Contest for Newbies-Round 5, which will be held at Thursday, July 25, 2024 at 12:30 UTC+5.5. You will be given 19 problems and 12 hours to solve them. Problems are sorted in difficulty order.

Plz Join this link.

UPD: The contest registration has been started.

UPD2: Congrats for the winners:

1)Banis [Perfect 19/19]

2)whitepalace [Perfect 19/19]

3)Console Crashers:V_egeTA,Kenil_Patel_183,tirthgohil1410

4)Luchador

5)d1312

First Solves:

A)whitepalace

B)gauravandbhagat

C)Luchador

D)Luchador

E)whitepalace

F)Luchador

G)whitepalace

H)whitepalace

I)whitepalace

J)Banis

K)whitepalace

L));:DeadMan69,geekyvishal,Rajdeep10

M)Banis

N)Banis

O)Luchador

P)Banis

Q)Banis

R)Banis

S)whitepalace

Полный текст и комментарии »

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

Автор AshnuB, история, 22 месяца назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in ICPC Beginner Contest for Newbies-Round 4, which will be held at Wednesday, July 24, 2024 at 10:05 UTC+5.5. You will be given 19 problems and 8 hours to solve them. Problems are sorted in difficulty order.

Plz Join this link.

UPD: The contest has been extended by 1 hour.

UPD2: Congrats for the winners:

1) Banis

2) YhuanDebeste

3) supremeashu

4) LakhimpurKheri

5) ...-_-...

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор AshnuB, история, 22 месяца назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in ICPC Beginner Contest for Newbies-Round 3, which will be held at Sunday, July 21, 2024 at 17:40 UTC+5.5. You will be given 19 problems and 48 hours to solve them. Problems are sorted in difficulty order.

Plz Join this link.

Congrats for the winners:

1) Skill Issue: wiseeldrich2004,vibhu_k2003,sojabhai

2) anango

3) Rohak

4) ;): Rajdeep10,DeadMan69,geekyvishal

5) whitepalace

Полный текст и комментарии »

  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится

Автор AshnuB, история, 22 месяца назад, По-английски

Hello, Codeforces!

I am pleased to invite you to participate in ICPC Beginner Contest for Newbies- Round 2, which will be held at Friday, July 19, 2024 at 15:05 UTC+5.5. You will be given 19 problems and 48 hours to solve them. The difficulty of contest is 1 star. Problems are sorted in difficulty order.

Plz Join this link.

Congrats for the winners:

1) spampots

2) kushagraG

3) anango

4) array

5) abo7ady

6) dualthread

7) sour_hub

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор AshnuB, история, 23 месяца назад, По-английски

Problem Statement Takahashi tried to type a string S consisting of lowercase English letters using a keyboard.

He was typing while looking only at the keyboard, not the screen.

Whenever he mistakenly typed a different lowercase English letter, he immediately pressed the backspace key. However, the backspace key was broken, so the mistakenly typed letter was not deleted, and the actual string typed was T.

He did not mistakenly press any keys other than those for lowercase English letters.

The characters in T that were not mistakenly typed are called correctly typed characters.

Count the number of subsequences in String T can form String S.

Constraints: S and T are strings of lowercase English letters with lengths between 1 and 2×(10)^5, inclusive.

Input: The input is given from Standard Input in the following format: S T

Output: Print number of subsequences of string T can form String S.

Sample Input 1: abc axbxyc

Sample Output 1: 1

Explaination: abc can form subsequence in (1,3 and 6) positions.

Sample Input 2: abac abacusabacus

Sample Output 2: 7

Explaination: abac can form subsequence in (1,2,3,4), (1,2,3,10),(1,2,7,10),(1,2,9,10),(1,8,9,10),(3,8,9,10) and (7,8,9,10) positions.

Sample Input 3: aaaaa aa

Sample Output 3: 0

What's the approach for this problem?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

Автор AshnuB, история, 2 года назад, По-английски

Hey from 4th problem of codechef starters felt difficult and from c problem of atcoder beginner feels difficult. what are the resources to do?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится