Advertisement
erfanul007

LightOJ 1198

Mar 12th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long int ull;
  5. typedef long long int ll;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scd(n) scanf("%lf",&n)
  18. #define scs(s) scanf("%s",s)
  19. #define pfi(n) printf("%d",n)
  20. #define pfl(n) printf("%lld",n)
  21. #define pff(n) cout<<n
  22. #define line printf("\n")
  23. #define spc printf(" ")
  24. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  25. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  26. #define cspf(i) printf("Case %d: ", i)
  27. #define pb push_back
  28. #define mp make_pair
  29. #define ff first
  30. #define ss second
  31. #define all(v) v.begin(),v.end()
  32. #define rall(v) v.rbegin(),v.rend()
  33. #define read() freopen("input.txt", "r", stdin)
  34. #define write() freopen("output.txt", "w", stdout)
  35. /// Constants
  36. #define eps 1e-9
  37. #define PI acos(-1.0) // 3.1415926535897932
  38. #define MAX 1000009
  39.  
  40. int main()
  41. {
  42. int tc;
  43. cin>>tc;
  44. loop(cs,1,tc){
  45. int n;
  46. cin>>n;
  47. vi t1(n),t2(n);
  48. loop(j,0,n-1){
  49. cin>>t1[j];
  50. }
  51. loop(j,0,n-1){
  52. cin>>t2[j];
  53. }
  54. sort(all(t1));
  55. sort(all(t2));
  56. int pnt=0;
  57. for(int i=0,j=0;i<n;i++,j++){
  58. if(t1[i]<t2[j]){
  59. j--;
  60. continue;
  61. }
  62. if(t1[i]>t2[j]){
  63. pnt+=2;
  64. continue;
  65. }
  66. if(t1[i]==t2[j]){
  67. bool flg=1;
  68. for(int x=i+1,y=j+1; x<n; x++,y++){
  69. if(t1[x]<=t2[y] && t1[x]>t1[i]){
  70. flg=0;
  71. break;
  72. }
  73. }
  74. if(flg){
  75. pnt++;
  76. }
  77. else{
  78. j--;
  79. }
  80. }
  81. }
  82. cspf(cs);
  83. pfi(pnt);line;
  84. }
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement