-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCUBARTWK.c
More file actions
35 lines (35 loc) · 713 Bytes
/
CUBARTWK.c
File metadata and controls
35 lines (35 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<stdio.h>
int main()
{
long long int w,d,i,sum,counth[30],countd[30],hw[30],hd[30];
while(1)
{
scanf("%lld %lld",&w,&d);
if(!w && !d)
break;
for(i=0;i<=20;i++)
{
counth[i]=0;
countd[i]=0;
}
for(i=0;i<w;i++)
{
scanf("%lld",&hw[i]);
counth[hw[i]]++;
}
for(i=0;i<d;i++)
{
scanf("%lld",&hd[i]);
countd[hd[i]]++;
}
sum=0;
for(i=0;i<=20;i++)
{
if(counth[i]>countd[i])
sum+=counth[i]*i;
else sum+=countd[i]*i;
}
printf("%lld\n",sum);
}
return 0;
}