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

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

Hello codeforces, I want to know whether there is any solution to this problem that is better than the naive O(N ^ 2) or not?

Problem:

You are given two arrays A and B. In each step, you can set A[i] = A[i] — B[i] if A[i] >= B[i]. Determine the minimum number of steps that are required to make all values of array A equal.

Print the minimum number of steps that are required to make all values of array A equal. If it is not possible, then print -1.

Constraints:

1 <= N, A[i], B[i] <= 5000

Sample Input

2

5 6

4 3

Sample Output

-1

Sample Input:

5

5 7 10 5 15

2 2 1 3 5

Sample Output:

8

Link to the Problem

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

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

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

Hie Codeforces, I'm abhishek from india and currently looking for a partner to participate with me in google hashcode 2021. if any of you is interested ,please do join the team here: https://hashcodejudge.withgoogle.com/#join-team/5005533501194240/Us8EAhGKT2u7c8CEeEY-PN7ofcAxrlTv0YNbM6lHeTI

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

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

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

Link to Problem:-https://cses.fi/problemset/task/1164

Code

can Someone please help me with my code..it is not working for some test cases..i have tried many test cases but could'nt find out my mistake

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

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