"I want to ask a question" - Ask them all here!

@vijju123, I have updated the post with problem link, please check.
And sorry about multiple revisions/edits, I tapped “Save edit” again and again because the site wasn’t loading quickly

I found the bug in my code. Now it gives TLE. At worst case, time complexity becomes linear when lower_bound finds an already assigned apartment. Here’s my code : https://ideone.com/38QCMR

Can you elaborate the 2 pointer approach ?

My 2 pointer approach

Same text here https://ideone.com/8M8tnI

i=j=0;
while(i<n&&j<m)
{
  if(a[i]-k<=b[j]&&b[j]<=a[i]+k)
  {
      j++;
      i++;
      ans++;//jth apartment given to i applicant
  }
  else if(b[j]<=a[i]-k)
  {
      j++;//b[j] cannot be given to anybody from i to n-1
  }
  else if(b[j]>=a[i]+k)
  {
      i++;//a[i] cannot get any apartment from b[j] to m-1
      //and j 0 to j-1 are already given
  }
}

https://tp-iiita.quora.com/The-Two-Pointer-Algorithm

http://codeforces.com/blog/entry/4586

One more thing i can say that if you have used vector used;

and then for insertion used push_back. used will be automatically sorted Then instead of running for find.
You can use upper_bound and lower_bound to find no of occurrences of an element in vector. And Can proceed.

Edited your comment @aryanc403 . Have a look for any corrections.

1 Like

Hi

Don’t know if this is the right place but I haven’t gotten my laddus for the March long contest. When will they be distributed? Got place 6 on div 1.

@fruition I can see your user handle as 2nd shortest code for this question. So congrats Man :slight_smile:

1 Like

@aryanc403 Thanks for all your help.

1 Like

Its taking time because of verification of 100% attendance laddus in my opinion. You will get them, just wait a few more days. Will ping @admin if you dont receive them after 2 days. Ok? :slight_smile:

There is problem in submission in this problem https://www.codechef.com/problems/FLOW007 and gives me compile time error and i used StringBuilder Class ( and it’s reverse function in the program) and this works fine on JRE
and when i click on compile time error to see what’s the error, it gives this “There was an error while serving this page. Please try again after some time”

1 Like

@kitydexter I suggest you to plz add your son link also. so that we can see where is problem along with your approach. e.g. in this case you should add https://www.codechef.com/viewsolution/17994605 , https://www.codechef.com/viewsolution/17994590 . Because nobody wants to go to your profile search for question and then search for your sol. I can already see you have got AC. so :slight_smile:

1 Like

import java.util.*;
public class ReverseNumber {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	Scanner sc = new Scanner(System.in);
		
		int times = sc.nextInt();
		for(int i=0;i<times;i++)
		{
			String s1= sc.next();
			StringBuilder sb = new StringBuilder(s1);
			sb.reverse();
		}	System.out.println(sb);

}

}
This is my solution @aryanc403, Thanks in advance :slight_smile:

1 Like

Your sol I have seen when I mentioned above links. And as it was in Java, and I don’t know java. So, didn’t read this. But don’t worry I will learn java this summer, then I will be help you out. I have mentioned those links because so that when you ask next question then you don’t forget to mention your approach links. And if you would have not got AC and another person who would have seen your question would have got links, so that he would be able to figure out mistake and help you out.

why code has been removed, that question (code) wasn’t related to any competition question?
Is there any restriction on doing that??

1 Like

@kitydexter are you talking about same answer, in which my comment was there ? If yes, then it is not deleted. https://discuss.codechef.com/questions/97820/i-want-to-ask-a-question-ask-them-all-here?sort=newest
I don’t know why this is not appearing. :slight_smile:

I dont get any context. And please dont upvote posts here, it makes it difficult for me to manage stuff here and I miss stuff. Upvote if I convert it to a question.

1 Like

@vijju123 context - since i upvoted @kitydexter answer. It has gone up. So, we also found it difficult to find that answer. And now I understood that how much difficult it would be when multiplied this by 100’s. so, I will keep this in mind in future. Also, plz can you add above comment on first line of this page. So, that next time anybody visits this page. He can also know this. :slight_smile:

I actually never needed to do that. People knew how to not make a mod’s life difficult :3 :stuck_out_tongue: :stuck_out_tongue: XD

1 Like

Haven’t gotten the laddus yet. Just need ~150 more to finally get my first t-shirt.