problem :: C. Vasya and Basketball link :: http://codeforces.com/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 »