PROBLEM LINK:Author and Editorialist: Hussain Kara Fallah PREREQUISITES:NONE PROBLEM:In the next month you are gonna solve problems. The month consists of $31$ days. You know for each day how many problems you will be solving at. You are given $D$ pairs of the form $(day_i,prob_i)$ denoting that you will solve $prob_i$ problems at the ${day_i}^{th}$ day of the month. You are given then $Q$ Queries of the form $(dead_i,req_i)$. For each query you have a deadline $dead_i$ which presents the last day that you could be solving problem at (the day itself is included). You need to tell if you will solve at least $req_i$ problems up to that day (answer is Yes/No). EXPLANATION:This problem is a straightforward translation of the words written in the statement. Due to low constraints, we can manage to keep the pairs of problemsolving events $(day_i,prob_i)$ in a vector/array. Afterward, for each query, we can iterate through all the problemsolving events. If the day corresponding to some event is the deadline day (or someday before) we can assume that we are gonna solve the number of problems planned for that day. We sum up all the problems amounts of these days. If our total sum is less than the required, we report that we cannot satisfy. Otherwise, we are fine. Check the author's code for the implementation of this approach. It runs in $O(Q*D)$. The tester's approach is a bit faster (but not needed for such constraints). We maintain an array $tot[1..31]$ recording how many problems we will solve each day. Let's run the following pseudocode:
Thus we will have in $tot_i$ the total number of problems we will solve from the first day till the $i_{th}$ day (included). Now our query $(dead_i,prob_i)$ can be answered faster. We can simply check $if(req_i<= tot[dead_i])$ and output the answer accordingly. Check the tester's implementation for details. This implementation runs in $O(Q)$ AUTHOR'S AND TESTER'S SOLUTIONS:
This question is marked "community wiki".
asked 23 Dec '18, 18:49

My solution is not being accepted. Can anyone please just give me a hint of what i am doing wrong?
answered 26 Dec '18, 21:04

for now, I would like you to check your output; it has to be "Go Camp" instead of "Go camp". both Camp and Sleep should be capitalized. I had the same bug only to discover after 7min of debugging that it was the content of my output stream. answered 26 Dec '18, 22:54

Can somebody check my code and tell why its not getting accepted?? https://pastebin.com/GgY3AhwG answered 27 Dec '18, 19:43

Please someone help me find error in my code.It is not being accepted.It shows Wrong Answer everytime. import java.util.*; import java.lang.*; class Ex
{
} answered 29 Dec '18, 00:50

@ssshauryaa you are getting an error because in line 23 the loop should start from i=2, not i=1, because for i=1, you are getting data from i1=0; ie. date=0 which is wrong.
Here is the corrected code:
answered 16 Feb, 10:43
