Skip to main content

Given an array/list of length ‘N’, where the array/list represents the boards and each element of the given array/list represents the length of each board. Some ‘K’ numbers of painters are available to paint these boards. Consider that each unit of a board takes 1 unit of time to paint.

 

Given an array/list of length ‘N’, where the array/list represents the boards and each element of the given array/list represents the length of each board. Some ‘K’ numbers of painters are available to paint these boards. Consider that each unit of a board takes 1 unit of time to paint.

You are supposed to return the area of the minimum time to get this job done of painting all the ‘N’ boards under a constraint that any painter will only paint the continuous sections of boards.

For Example :
In the below figure where array/list elements are {2, 1, 5, 6, 2, 3}.

alt text

A painter can paint blocks {5,6} or {1,5,6,2} together but not {2,5,6} or {5,6,3}.
Input Format :
The first line contains a single integer ‘T’ denoting the number of test cases.

The first line of each test case contains two integers ‘N’ and ‘K’ denoting the number of elements in the array/list and number of painters available.

The second line contains ‘N’ single space-separated integers denoting the elements of the array/list.
Output Format :
For each test case, print the minimum time required to get the job done.
Note :
You do not need to print anything; it has already been taken care of.
Constraints :
1 <= T <= 5
1 <= N <= 10^4
1 <= K <= N
1 <= ARR[i] <= 10^5

Where ‘T’ is the number of test cases.
'N' is the length of the given array/list (boards).
‘K’ is the number of painters available.
And, ARR[i] denotes the i-th element in the array/list.

Time Limit: 1 sec.
Sample Input 1 :
2
4 2
5 5 5 5
4 2
10 20 30 40
Sample Output 1 :
10
60
Explanation For Sample Input 1 :
In the first test case, we can divide the boards into 2 equal-sized partitions, so each painter gets 10 units of the board and the total time taken is 10.


In the second test case, we can divide the first 3 boards for one painter and the last board for the second painter.
Sample Input 2 :
2
2 2
48 90
4 2
1 2 3 4
Sample Output 2 :
90
6
Solution in python:
def painter(boards,cap):
    n=len(boards)
    remcap=cap
    painter1=1
    for i in range(n):  
        if boards[i]<=remcap:
            remcap-= boards[i]
        else:
            painter1=painter1+1
            remcap=cap
            remcap-=boards[i]
    return painter1

Comments

Popular posts from this blog

Jhadol Premier league Season - 8 (JPL 2022)

  आपने आईपीएल (इंडियन प्रीमियर लीग) के बारे मे सुना होगा। उसी तरह हमारे गांव झाडोल में झाडोल प्रीमियर लीग सीज़न -8(JPL-2022) आयोजित हो रहा है | जिसका आयोजन मातेश्वरी क्लब झाडोल द्वारा किया जा रहा है। यह एक रात्रि कालीन टूर्नामेंट है। इस टूर्नामेंट में कई क्रिकेट प्रेमी भाग लेंगे और अपना सर्वश्रेष्ठ खेल खेलेंगे। इस टूर्नामेंट में मुख्यत 12 Teams partcipate करेगी। सभी 12 टीमों के अपने प्रायोजक (Sponsors) हैं और प्रत्येक टीम में 6 खिलाड़ी हैं। खिलाड़ियों का चयन नीलामी (auction)प्रणाली के आधार पर किया जाएगा। प्रायोजक(Sponsors) कप्तान का चयन करेंगे। इस टूर्नामेंट के लिए चुना गया खेल का मैदान नया बस स्टैंड झाडोल (New bus stand) है और निर्धारित तिथि 26-28 अक्टूबर है। उनके कुछ नियम और कानून नीचे दिए गए हैं। इन नियमों का पालन सभी को करना चाहिए। Jhadol Premier league 1. यह एक रात्रिकालीन क्रिकेट प्रतियोगिता होगी जिसमे ग्राम पंचायत झाडोल के खिलाड़ी ही भाग ले सकते है। 2. प्रतियोगिता में खिलाडियो का चयन नीलामी (Auction) पद्धति के आधार पर होगा। 3. प्रतियोगिता लीग मैच पद्धति के आधार पर खेल...

Dr Pooja Tripathi ने Rahul Gandhi की भारत जोड़ो यात्रा को महात्मा गांधी की यात्राओं के समतुल्य बताया।

 Dr Pooja Tripathi ने Rahul Gandhi की भारत जोड़ो यात्रा को महात्मा गांधी की यात्राओं के समतुल्य बताया। Dr Pooja Tripathi ने ट्वीट किया की "इस तस्वीर में राहुल जी की सूरत तो देखिए । चेहरा डार्क हो गया है । बालो मे धूल है। सफेद दाढ़ी हैं। कुछ यात्राओं ने गांधी को महात्मा बना दिया था । जब भारत जोड़ो यात्रा अंजाम पर पहुंचेगी , झुलसे चहरे और दाढ़ी वाले  इस गांधी को देखकर लोग इनमे हिंदुस्तान देखेंगे। राहुल गांधी भारत जोड़ो यात्रा

वैश्विक मार्केट में भारतीय जुट कारोबार को बहोत लाभ हुआ हे

 भारत मे बने जुट बैग वैश्विक हुए, यूनाइटेड स्टेटके सुपर मार्केट से फ्रांस के फैशन हाउस तक किए जा रहे पसंद  जैसा aapko मालूम ही है कि प्लास्टिक के बैग के उपयोग से वातावरण को कितना नुकसान हो रहा है । इसी बीच भारत मे बने जुट के बैग विश्व के लिए वरदान बन चुके है । इससे वैश्विक मार्केट में भारतीय जुट कारोबार को बहोत लाभ हुआ हे । जुट के मजबूत रेशे से कपड़ा (मोटा टाट) बनाया जाता है । सदियों से इस जुट की खेती गंगा के डेल्टा की आर्द्र और गर्म जलवायु मे कि जाती हे। 

upcoming it hub in bangalore

 Karnataka is indeed planning a new IT hub in Sarjapur, located approximately 32 km from Bengaluru. This ambitious project aims to replicate the success of existing tech zones like Electronics City and Whitefield's International Tech Park.upcoming it hub in bangalore Key details about the new IT hub:  * Location: Sarjapur, 32 km from Bengaluru  * Land Area: 1,050 acres  * Developer: Karnataka Industrial Areas Development Board (KIADB)  * Objective: To drive economic growth, foster innovation, and create job opportunities Potential Benefits:  * Economic Growth: The new hub is expected to attract significant investment and generate employment opportunities.  * Innovation Hub: It aims to foster a vibrant startup ecosystem and encourage innovation.  * Infrastructure Development: The development of the IT hub may lead to improved infrastructure in the surrounding areas. Challenges and Considerations:  * Urban Congestion: The development of the IT ...

नौकरी नहीं, केस: SI भर्ती रद्द — हाईकोर्ट का फैसला

 नौकरी नहीं, केस: SI भर्ती रद्द — हाईकोर्ट का फैसला राजस्थान SI भर्ती 2021 रद्द; हाईकोर्ट ने तीन मुख्य बिंदुओं पर दिया आदेश दिनांक: 28 अगस्त 2025 मुख्य बातें: राजस्थान हाईकोर्ट ने पुलिस SI भर्ती परीक्षा 2021 को रद्द कर दिया है, यह फैसला आज सुनाया गया।  Navbharat Times +1 कोर्ट ने यह निर्णय तीन मुख्य आधारों पर लिया: चयन प्रक्रिया में पारदर्शिता का अभाव नियमों का उल्लंघन उम्मीदवारों के साथ अन्याय होना—इन सब पर कोर्ट ने कड़ी टिप्पणी की।  Navbharat Times अतिरिक्त विवरण — नवभारत टाइम्स की रिपोर्ट के अनुसार, भर्ती 859 पदों के लिए थी, पर इसमें पेपर लीक और फर्जीवाड़े के आरोपों के कारण यह रद्द कर दी गई है। अब नए SI भर्ती में रद्द किए गए पद (जोड़कर कुल 897 पद) शामिल किए जाने की संभावना बनी हुई है।  Navbharat Times फौरन कार्रवाई — भर्ती रद्द होने पर नई प्रक्रिया की राह Live Hindustan की रिपोर्ट में कहा गया है कि RPSC ने 2025 में SI और Platoon Commander की नए पदों (1,015 पदों) पर भर्ती प्रक्रिया शुरू कर दी है। आवेदन 10 अगस्त से चल रहे हैं और अंतिम तिथि 8 सितंबर है। नई परीक्षा की स...

REET 2022:REET Mains Exam Date release, Notification & Latest Updates| REET level 2 controversy

  REET 2022 pre has been successfully conducted. The REET Mains Exam Date is 4th-5th February 2023. Their is one controversy generated. level 2 students blaiming to government that they have cut down  6000 seats and added in level 1 . Check the information for Notification, Vacancy, and Latest News for Preliminary and Mains exams REET Mains Exam Date is already declared. The exam is scheduled to be held on 4th February 2023 and 5th February 2023. The preliminary exams have been successfully completed and the result is already declared. The candidates who have successfully qualified the exam can apply for the mains exam. Candidates can check the result on the official website. The exam is conducted in level 1 and level 2 prelims exams and result for the same is already released by the Rajasthan Board of Secondary Education (BSER) on the official website. Rajasthan Board of Secondary Education administers the Rajasthan Eligibility Test for teachers. REET ensures fantastic opport...

bc gambling sites, how to win money

 bc gambling sites, how to win money  Winning money on BC gambling sites, like PlayNow.com, primarily depends on luck, skill, and the type of game you're playing. While there are no guaranteed ways to win, there are strategies you can use to maximize your chances of success. However, it’s important to remember that gambling should always be done responsibly and within your means.  ### 1. **PlayNow.com (BC's Legal Gambling Site)**   As mentioned earlier, **PlayNow.com** is the official and legal gambling platform in British Columbia. The site offers various gambling options, including: - **Casino Games** (slots, blackjack, roulette, etc.) - **Sports Betting** (bet on various sports, including hockey, football, soccer, etc.) - **Poker** - **Lottery Tickets** ### 2. **Ways to Maximize Your Chances of Winning** While there is no foolproof method to win, here are some general strategies for different types of gambling: #### **Casino Games** - **Slot Machines**: ...

चीन में कोरोना ब्लास्ट,आज से 10 लाख लोगों को iPhone फैक्ट्री के पास किया बंद

  Zhengzhou के आईफोन मैन्युफैक्चरिंग हब ने अपने सबसे अधिक आबादी वाले जिलों में से एक को कोरोना वायरस के प्रकोप को रोकने के लिए बंद कर दिया, पूरे चीन में रेंगने वाले प्रतिबंधों के साथ व्यवधान कंपनियों के लगातार खतरे को रेखांकित किया, जबकि देश कोविड ज़ीरो से चिपक गया। सरकारी नोटिस के अनुसार, झोंगयुआन जिले के लगभग 1 मिलियन निवासियों को सोमवार से घर पर रहने का आदेश दिया गया था, सिवाय इसके कि जब उन्हें कोविड परीक्षण से गुजरना पड़े, और गैर-जरूरी व्यवसाय बंद कर दिए गए हों। व्यापक प्रतिबंध पिछले सप्ताह कुछ मोहल्लों में तालाबंदी का पालन करते हैं, कई लोगों को आश्चर्यचकित करने के बाद अधिकारियों ने कहा कि शहर भर में तालाबंदी नहीं होगी। आईफोन बनाने वाली कंपनी फॉक्सकॉन टेक्नोलॉजी ग्रुप के प्लांट लॉकडाउन वाले जिले में नहीं हैं। कंपनी के प्रतिनिधियों ने ब्लूमबर्ग न्यूज की टिप्पणी के अनुरोध का तुरंत जवाब नहीं दिया। शहर ने रविवार के लिए 6 नए स्थानीय मामले दर्ज किए, जो 9 अक्टूबर को हाल ही में 40 के शिखर से नीचे थे। राष्ट्रव्यापी, मामलों में घटकर 697 हो गए, जो दो सप्ताह में सबसे कम है, क्योंकि इनर ...

TCS Xplore IRA 6thSep2021 Python and Java SBQ

Create a class Leave with the below attributes:   leaveId of type int leaveType of type String having values as EL/CL/SL noOfDays type int dateOfApplication of type String in the format dd-mm-yy (12-07-21)   Note: leaveType EL represents Earned Leave, CL is Casual Leave and SL is Sick Leave. Assume that Leave details are only for the year 2021.     Create the init method which takes the parameters in the above sequence. The method should set the value of attributes to parameter values.     Create another class Employee with the below two attributes: 1. leaveList of type List having Leave objects 2. leaveBalance of type Dictionary having leaveType as Key and remaining leaves of that type as Value. Eg. {EL:20,CL:2,SL:31}   Create the init method which takes all parameters in the above sequence. The method should set the value of attributes to parameter values inside the method. Create below two methods inside the Employee class:   1. getUpdated...

The average price of 20 paint brush is $15 while average prices of 18 of those is $12 . for the remaining 2 brushes the prices of 1 is 40% more than that of other

 ques 1 .The average price of 20 paint brush is $15 while average prices of 18 of those is $12 . for the remaining 2 brushes the prices of 1 is 40% more than that of other? answer: brush is $35 and other is $49.  ques 2 .the length and breadth of a rectangular field are 45 m and 30m respectively. find the ratio of the breadth to the length of the field? answer: breadth /length=30/45=2/3=2:3.  ques 3 .A certain distance is covered at a certain speed .if half the distance is covered in double the time,the ratio of the two speeds is? answer: 4:1.  ques 4 .Aman sells 5 articles for rs 15 and makes a profit of 20% .find his gain or loss percent if he sells 8 such articles for Rs 18.40? answer: 8%  loss.  ques 5. In what ratio should  a 20 % methyl alcohol solution be mixed with 50% methyl alcohol solution so that the resultant solution  has 40% methyl alcohol in it? answer: 1:2 .