Sunday, April 30, 2017

URI Solution 1104 Exchanging Cards - Solution in C++ | Ad Hoc

URI Solution 1104 Exchanging Cards - Solution in C++ | Ad Hoc


URI Online Judge Solution  | Ad Hoc


Problem Name: URI Problem - Exchanging Cards
Problem Number : URI - 1104
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1104 Code in CPP:


#include <stdio.h>
#include <string.h>

int alice[100001];
int beatriz[100001];

int main(int argc, char const *argv[])
{
 int a, b, x, i, c, al, be;

 while(scanf("%d %d", &a, &b) && (a || b))
 { 
  memset(alice, 0, sizeof(alice));
  memset(beatriz, 0, sizeof(beatriz));
  c = 0, al = 0, be = 0;

  for (i = 0; i < a; ++i)
  {
   scanf("%d", &x);
   alice[x]++;
  }
  
  for (i = 0; i < b; ++i)
  {
   scanf("%d", &x);
   beatriz[x]++;
  }

  for (i = 0; i < 100001; ++i)
  {
   if(alice[i] != 0 && beatriz[i] == 0)
    al++;
   if(alice[i] == 0 && beatriz[i] != 0)
    be++;
  }

  if(al < be) printf("%d\n", al);
  else printf("%d\n", be);
 }

 return 0;
}

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.