Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Constraints: 1 <= R <= 108 1 <= N <= 20 1 <= A[i] <= 108 Time Limit : 2s Input: First line contains R and N. Second line contains the array A. Output: Print the answer in a single line, followed by a '\n' ( just print a new line, no need to display '\n' ) Sample Case 1: Input: 20 5 5 10 3 25 9 Output: 22\n Explanation: You can pay him 10 + 3 + 9 = 22, any other combination is more than 22 or less than 20. Sample Case 2: Input: 10 3 513 Output: -1\n Explanation: You don't have enough money :(
Input: Only one line containing N R M. Output: Print the answer in a single line, followed by a '\n' ( just print a new line, no need to display '\n' ) Time Limit: 2s Sample Case 1: Input: 538 Output: 2\n Explanation: Out of N = 5 items, we can select R = 3 items in 10 ways and ( 10 % 8 ) = 2 Sample Case 2: Input: 1000 112 1003 Output: 666\n Explanation: Take care of modulo operator while dealing with such large values. You may have to take modulo of intermediate values, to avoid overflows.
Constraints: N integer ranges are given. 1 <= N <= 1000 Each range [A..B] is such that 1 <= A <= B <= 109 1 <= K <= total number of integers in the union of the ranges Note that you need to use long long for K Time Limit : 1s Input: First line contains N and K. N lines follow, each contains A B, which is the interval [A..B] Output: Print the Kth smallest integer in the union of the sets, in a single line, followed by a '\n' ( just print a new line, no need to display '\n' ) Sample Case 1: Input: 3 11 15 38 24 Output: 5\n Explanation: Union = {1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8} and the 11th smallest integer is 5
Objective : You have to turn on all lights using minimum flips. Constraints: 1 <= R,C <= 100 Time limit : 1s Input : First line contains R(1<=R<=100) and C(1<=C<=100) following line contains the matrix(R X C) input Output : Print the answer in a single line, followed by a '\n' ( print new line, no need to display '\n' )
Examples : Input : 23 111 101 Output : 4\n Input : 33 111 000 000 Output: 2\n
Problem G : Hangout
Dhookudu movie ki vellakunda lab ki enduku vacham raa devudaaa ! haha.. thats telugu and I'm sure most of you didn't understand it. How can you understand if you don't hangout with friends from different states. To make things better, your batchmates decided to form small groups, each group having exactly K students and no two of them in a group from same state. There are N states in India and you are given the number of students from each of them. How many maximum groups can you form ? Constraints: 1 <= N <= 100 2 <= K <= 100 1 <= A[i] <= 109 Time Limit : 1s Input: First line contains N and K. Second line contains the array A. A[i] is the number of students from ith state. Output: Print the answer in a single line, followed by a '\n' ( just print a new line, no need to display '\n' ). Note that you may need to use long long for the answer. Sample Case 1: Input: 43 2436 Output: 4\n Explanation: Let the 4 states be A, B, C, D and we have 2 from A, 4 from B, 3 from C and 6 from D. Each group should contain 3 students from different states. We can form the following groups {A,B,C}, {A,B,D}, {B,C,D}, {B,C,D}. Note that we can't form more than 4 groups, though there are 15 students in total. Sample Case 2: Input: 64 10 11 12 13 14 15 Output: 18\n Explanation: (A,B,D,E) 3 times (A,C,D,E) 3 times (A,C,D,F) 4 times (B,C,E,F) 5 times (B,D,E,F) 3 times