moaz123's blog

By moaz123, history, 9 years ago, In English

Hey everyone, how are you?

I am getting Time limit in this problem with a complexity of O(n log n) n<=10^5. I tried to see if something is overlapping, but couldn't find any. Thanks everyone.

And sorry for my bad English.

submission link: http://codeforces.net/contest/675/submission/18651358. Organized code Link: https://codeshare.io/leZMR

Full text and comments »

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

By moaz123, history, 9 years ago, In English

Hey everyone :), how are you? I was reading a couple of CF blogs. And I was thinking how much is it awesome to have a great community in one place. and I wanted to know your opinion on how did codeforces community help you or affect you? is it inspiring , motivating ..etc? or even nothing ?

I solve CF problems every once in a while, but I never really interacted with the community itself, but I am looking forward to.

I hope you all are good and have great time ^^. Peace!

Full text and comments »

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

By moaz123, history, 9 years ago, In English

hey everyone , i am kind of new to writing blogs on codeforces so excuse me if I made any mistakes :) .

i am having a problem with problem (B. New Year and Old Property) (http://codeforces.net/problemset/problem/611/B) . I have been working on it for like 3 days and still not getting any progress .

You can find the code in the link : https://codeshare.io/ffeXX .

I don't know if i should explain the code or not but i will explain it in the link .

Thanks everyone for the great help .

Full text and comments »

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

By moaz123, history, 10 years ago, In English

11681209

http://codeforces.net/problemset/problem/538/C

i have been stuck in this problem for like 2 days and i can't move to another one . i am so close . testcase wrong answer . wrong answer 1st words differ — expected: '219', found: '218' so annoying . :D

here is my code i hope you can help

include <bits/stdc++.h>

using namespace std;

int totaltime,n; pair < int , int > arr[100005];

int main() { scanf("%d %d",&totaltime,&n);

for(int i=1; i<=n; i++)
{
    cin>>arr[i].first;
    cin>>arr[i].second;
}
arr[0].first=arr[0].second=0;
int ans=0;
for(int i=1; i<=n; i++)
{
   // cout<<ans<<endl;
    if( abs(arr[i].second-arr[i-1].second) > abs(arr[i].first-arr[i-1].first)&&i!=1)
    {
     //   cout<<i<<endl;
        cout<<"IMPOSSIBLE\n";
        return 0;
    }
    else
        {
            //if((abs(arr[i].first-arr[i-1].first)%2==0))ans= max (ans, ((abs(arr[i].first-arr[i-1].first) - abs(arr[i].second-arr[i-1].second))/2) + arr[i-1].second );

            ans= max (ans, ((abs(arr[i].first-arr[i-1].first) - abs(arr[i].second-arr[i-1].second))/2) + arr[i-1].second );
        }

}

// cout<<ans<<endl; ans=max(ans,arr[n].second+totaltime-arr[n].first); cout<<ans<<endl;

return 0;

}

Full text and comments »

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

By moaz123, 10 years ago, In English

problem :: C. Vasya and Basketball link :: http://codeforces.net/problemset/problem/493/C

i tried to change my code over and over again but same result (wrong answer at test case 6) i don't know why ? can someone give me a hint or something .

that's my code . thanks !

include

include <stdio.h>

include

include <string.h>

include

include

include

include

include

include <math.h>

using namespace std;

long int T1,T2; vectorarr1; set a;

bool binarysearch(long int s) { long int mid,high=T1,low=0; while(high>low+1) { mid=(high+low)/2;

if(arr1[mid]==s)
        return true;

    if(arr1[mid]<s)
        low=mid -1;

    else
        high = mid +1;
}
return false;

}

int main() {

cin>>T1;
long int q;
for(long int i=0; i<T1; i++)
{
    cin>>q;
    arr1.push_back(q);
    a.insert(q);
}
sort(arr1.begin(),arr1.end());

cin>>T2;

for(long int i=0; i<T2; i++)
{
    cin>>q;
    a.insert(q);
}


long int r1=0,r2=0,ans1=0,ans2=0;
for( set<long int>::iterator i=a.begin(); i!=a.end(); i++)
{
    if(binary_search(arr1.begin(),arr1.end(),*i))
        r1++;

    else
        r2++;

    if(r2>r1)
    {
        ans1+=r1*2;
        ans2+=r2*2;
        r1=0;
        r2=0;
    }

}
cout<<ans1+(r1*3)<<":"<<ans2+(r2*3)<<endl;
return 0;

}

really sorry if i wasn't clear enough !!

Full text and comments »

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