Advertisement
Saleh127

Lo 1198

Aug 17th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);cout.tie(0);
  7. int t,l;
  8. cin>>t;
  9. for(l=1;l<=t;l++)
  10. {
  11.  
  12. int a[2000],c[2000],d,e,f,i,j,k,as=0;
  13. cin>>d;
  14. for(i=0;i<d;i++)
  15. {
  16. cin>>a[i];
  17. }
  18. for(i=0;i<d;i++)
  19. {
  20. cin>>c[i];
  21. }
  22. sort(a,a+d);
  23. sort(c,c+d,greater<int>());
  24. for(i=0;i<d;i++)
  25. {
  26. if(a[i]>0)
  27. {
  28. for(j=0;j<d;j++)
  29. {
  30. if(c[j]>0)
  31. {
  32. if(a[i]>c[j])
  33. {
  34. as+=2;
  35. a[i]=c[j]=-1;
  36. break;
  37. }
  38. }
  39. }
  40. }
  41. }
  42. for(i=0;i<d;i++)
  43. {
  44. if(a[i]>0)
  45. {
  46. for(j=0;j<d;j++)
  47. {
  48. if(c[j]>0)
  49. {
  50. if(a[i]==c[j])
  51. {
  52. as+=1;
  53. a[i]=c[j]=-1;
  54. break;
  55. }
  56. }
  57. }
  58. }
  59. }
  60. cout<<"Case "<<l<<": "<<as<<endl;
  61. }
  62. return 0;
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement