Binod And Subarray SOLUTIONS BINARR

Binod And Subarray SOLUTIONS BINARR

Binod is a youtuber and he is occupied in the acclaim of web-based media so he requested that you assist him with tackling an issue. You have been given a variety of 

positive numbers a1,a2,a3,…,ai,…,an of size n.You need to locate the littlest length of the subarray with the end goal that the length of the subarray must be carefully more noteworthy than k and it’s total likewise should be carefully more prominent than s. 

 

Information Format :- 

The primary line of information contains three space-isolated whole numbers n, k and s 

The subsequent line contains n space-isolated integers,describing the cluster a 

 

Yield Format: 

Print a solitary whole number :- The littlest length of subarray if exists, Otherwise print “- 1” (without cites) 

 

Limitations:- 

1≤n,k≤106 

1≤a1,a2,a3,…,ai,…,an≤109 

1≤s≤1015 

Subtask #1 (30 focuses): 

1≤n,k≤103 

Subtask #2 (70 focuses): 

Unique Constraints 

 

Test Cases:- 

Model 1: 

5 1 5 

1 2 3 4 5 

 

Yield : 

 

Clarification

There are two possibles answers: 

Record begins at 3 and closures at 4 have a total of 7 which is carefully more noteworthy than 5 and has a length of subarray more prominent than 2. 

List begins at 4 and closures at 5 have a total of 9 which is carefully more noteworthy than 5 and has a length of subarray more prominent than 2. 

Any of the potential situations offers a similar response. 

 

Model 2: 

3 2 1 

9 1 

 

Yield : 

3

 

Clarification : 

Each incentive in exhibit record fulfills the condition whole more noteworthy than 1 however to fulfill the state of length more prominent than 2 pick the subarray of length 3

 

CODE PYTHON 3.6 :
 

 

n,k,s =map(int,input().split())
arr = list(map(int,input().split()))
k+=1
 
rlt=i=0
while i<n+1-k:
    if sum(arr[i:i+k])>s:
        rlt=k
        print(rlt)
        break
    i+=1
    if i>=n+1-k:
        i=0
        k+=1
if rlt==0:
    print(-1)

 

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment

close
error: Content is protected !!
Free Udemy Courses and Hacking Resources Join Us on TelegramClick Here
+