here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Tuesday 9 June 2015

War


problem statement is here


#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
long long int s,ar[100009],br[100009],i,j,z,p,a;
scanf("%lld",&s);
for(i=0;i<s;i++){
scanf("%lld",&ar[i]);
}
for(i=0;i<s;i++){
scanf("%lld",&br[i]);
}
sort(ar,ar+s);
sort(br,br+s);
z=s-1;p=0;
for(i=s-1;i>=0;i--){
if(ar[i]<br[z]){
p++;
z--;
}
}
printf("%lld\n",p);
return 0;
}

No comments:

Post a Comment