pranshukas's blog

By pranshukas, history, 4 years ago, In English

I am using Sublime Text Editor for Writing C++ Programs but it's taking too much time to Compile even small Programs. Even printing Hello World takes 4-5s.

I have been using Windows 10, My PC Configuration is — i7 9750H, 16GB Ram, and 512GB SSD. I am still wondering why is it still slow. I have seen many Competitive Programmers during screencasting videos using Sublime text and their Compile Time is merely 0.8-1.2s. But mine is taking too much time which cost me patience and time During Contests.

One thing that I have seen is those Competitive Programmers were using macOS or Linux. I was wondering if Sublime Text really slow on Windows or I have done some mistakes while installing it.

I have tried Googling my Problem but unable to find any solution, I had asked this Question on Stackoverflow also but there also I didn't get any reply.

Please Someone Help me fixing it or comment on some related article that I can read to fix it.

Below is ScreenShot even this small Program took 15.3s ->

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By pranshukas, 4 years ago, In English

Problem Link: 1301B - День рождения Мотарака

I am facing some difficulties while solving this problem. Can Anyone Help me?

Here's my Pseudo Code(Below): I have used Binary Search to approach the problem. I am applying Search over range 0-10^9 and inserting my mid-value at the position where arr[i]= -1 and taking the absolute differences if I find that the maximum absolute difference after replacing -1 with mid was less than my temporary answer, I just update my value. But It's giving Wrong answers. Please Someone explain Where I'm Getting Wrong. What changes Do I need to make...

#define ll long long 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
ll check(ll mid, ll *arr, ll n)
{
    ll ans=0;
    rep(i,1,n)
    {
        if(arr[i]==-1 and arr[i-1]!=-1) ans=max(ans,abs(mid-arr[i-1]));
        if(arr[i]!=-1)
        {
            if(arr[i-1]==-1) ans=max(ans,abs(arr[i]-mid));
            else ans=max(ans,abs(arr[i]-arr[i-1]));
        }
    }return ans;

}
void solve()
{
    ll n;  cin>>n;
    ll arr[n];
    rep(i,0,n) cin>>arr[i];
    ll low=0,high=1000000000,ans=1e9+7,k;
    while(low<high)
    {
        ll mid=(low+high)/2;
        ll temp=check(mid, arr, n);
        if(temp<=ans)
        {
            ans=min(temp,ans);
            k=mid;
            high=mid;
        }
        else low=mid+1;
    }cout<<ans<<" "<<k<<"\n";

}

Thanks for Help !!!!

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By pranshukas, history, 4 years ago, In English

I need help with this Problem Traffic Lights. CSES Problem Set under Sorting and Searching. I thought of an approach that

  1. create a set add elements at every step,

  2. Traverse the set and take the difference and take the maximum out of it.

  3. display maximum at every step.

But I think this is a very naive approach and Time Complexity would be O(n^2) and n can be up to 10^5, so most of my Test Cases are giving TLE.

I am not able to think of another approach. Can Anyone give me a hint, how should I approach it.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it