Problem:


Score : 400 points

Problem Statement

On a two-dimensional plane, there are N red points and N blue points.
The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).

A red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.

At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.

Constraints

All input values are integers.

1 \leq N \leq 100

0 \leq a_i, b_i, c_i, d_i < 2N

a_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.

b_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
a_2 b_2
:
a_N b_N
c_1 d_1
c_2 d_2
:
c_N d_N

Output

Print the maximum number of friendly pairs.

Sample Input 1

3
2 0
3 1
1 3
4 2
0 4
5 5

Sample Output 1

2

For example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).

Sample Input 2

3
0 0
1 1
5 2
2 3
3 4
4 5

Sample Output 2

2

For example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).

Sample Input 3

2
2 2
3 3
0 0
1 1

Sample Output 3

0

It is possible that no pair can be formed.

Sample Input 4

5
0 0
7 3
2 2
4 8
1 6
8 5
6 9
5 4
9 1
3 7

Sample Output 4

5

Sample Input 5

5
0 0
1 1
5 5
6 6
7 7
2 2
3 3
4 4
8 8
9 9

Sample Output 5

4



Sample input:
3
2 0
3 1
1 3
4 2
0 4
5 5


Sample output:
2

Submission status: Wrong Answer

Solution code:
n = int(input())
red = [[0,0]]*n
for i in range( n ):
    red[i] = list(map(int, input().split()))
    
    red.sort(key = lambda p:p[0])
    red.sort(key = lambda p:p[1], reverse = True) 
    
blue = [ list( map(int,input().split()) ) for i in range( n )]
blue.sort(key = lambda p:p[0])
    
paired = [False] * len(blue)
ans = 0
    
for i in range(n):
    for j in range(n):
            
        if paired[j]:
            continue
            
        if red[i][0] < blue[j][0] and \
            red[i][1] < blue[j][1] :# and \
                #paired[j] is False:
    #        print('{}, {}'.format(red[i],blue[j]))
            paired[j] = True
            ans += 1
            break
                
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = [[0,0]]*n
for i in range( n ):
    red[i] = list(map(int, input().split()))
    red.sort(key = lambda p:p[1], reverse = True) 
    red.sort(key = lambda p:p[0])
    
blue = [ list( map(int,input().split()) ) for i in range( n )]
blue.sort(key = lambda p:p[0])
    
paired = [False] * len(blue)
ans = 0
    
for i in range(n):
    for j in range(n):
            
        if paired[j]:
            continue
            
        if red[i][0] < blue[j][0] and \
            red[i][1] < blue[j][1] :# and \
                #paired[j] is False:
    #        print('{}, {}'.format(red[i],blue[j]))
            paired[j] = True
            ans += 1
            break
                
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = [[0,0]]*n
for i in range( n ):
    red[i] = list(map(int, input().split()))
    red.sort(key = lambda p:p[0])
    red.sort(key = lambda p:p[1], reverse = True) 
    
blue = [ list( map(int,input().split()) ) for i in range( n )]
blue.sort(key = lambda p:p[0])
    
paired = [False] * len(blue)
ans = 0
    
for i in range(n):
    for j in range(n):
            
        if paired[j]:
            continue
            
        if red[i][0] < blue[j][0] and \
            red[i][1] < blue[j][1] :# and \
                #paired[j] is False:
    #        print('{}, {}'.format(red[i],blue[j]))
            paired[j] = True
            ans += 1
            break
                
print(ans)

Submission status: Wrong Answer

Solution code:
 
n = int(input())
rx,ry = [0]*n,[0]*n
for i in range(n):
  rx[i], ry[i] = map(int, input().split())
  
bx, by = [0]*n,[0]*n
for i in range(n):
  bx[i], by[i] = map(int, input().split())
 
red = [[0,0]]*len(rx)
for i in range( len(rx) ):
    red[i] = rx[i], ry[i]
    red.sort(key = lambda p:p[0])
    red.sort(key = lambda p:p[1], reverse = True) 
    
blue = [ (bx[i],by[i]) for i in range( len(bx) )]
blue.sort(key = lambda p:p[0])
    
paired = [False] * len(blue)
ans = 0
    
for i in range(len(rx)):
    for j in range(len(bx)):
            
        if paired[j]:
            continue
            
        if red[i][0] < blue[j][0] and \
            red[i][1] < blue[j][1] :# and \
                #paired[j] is False:
    #        print('{}, {}'.format(red[i],blue[j]))
            paired[j] = True
            ans += 1
            break
                
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(N)]
sum_ab = [li[0]+li[1] for li in ab]
sum_cd = [li[0]+li[1] for li in cd]
enu_ab = [[i, sum_ab[i]] for i in range(N)]
enu_cd = [[i, sum_cd[i]] for i in range(N)]
sort_ab = sorted(enu_ab, key=lambda x: x[1])
sort_cd = sorted(enu_cd, key=lambda x: x[1])
count = 0
ab_count = []
cd_count = []

for i in range(N):
    for j in range(N):
        if sort_ab[i][1] < sort_cd[j][1]:
            idx_ab = sort_ab[i][0]
            idx_cd = sort_cd[j][0]
            if idx_ab not in ab_count and idx_cd not in cd_count and ab[idx_ab] < cd[idx_cd]:
                count += 1
                ab_count.append(idx_ab)
                cd_count.append(idx_cd)
print(count)

Submission status: Wrong Answer

Solution code:
 
n = int(input())
rx,ry = [0]*n,[0]*n
for i in range(n):
  rx[i], ry[i] = map(int, input().split())
  
bx, by = [0]*n,[0]*n
for i in range(n):
  bx[i], by[i] = map(int, input().split())
 
red = [[0,0]]*len(rx)
for i in range( len(rx) ):
    red[i] = rx[i], ry[i]
    red.sort(key = lambda p:p[0])
    red.sort(key = lambda p:p[1], reverse = True) 
    
blue = [ (bx[i],by[i]) for i in range( len(bx) )]
blue.sort()
    
paired = [False] * len(blue)
ans = 0
    
for i in range(len(rx)):
    for j in range(len(bx)):
            
        if paired[j]:
            continue
            
        if red[i][0] < blue[j][0] and \
            red[i][1] < blue[j][1] :# and \
                #paired[j] is False:
    #        print('{}, {}'.format(red[i],blue[j]))
            paired[j] = True
            ans += 1
            break
                
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(N)]
sum_ab = [li[0]+li[1] for li in ab]
sum_cd = [li[0]+li[1] for li in cd]
enu_ab = [[i, sum_ab[i]] for i in range(N)]
enu_cd = [[i, sum_cd[i]] for i in range(N)]
sort_ab = sorted(enu_ab, key=lambda x: x[1])
sort_cd = sorted(enu_cd, key=lambda x: x[1])
count = 0
ab_count = []
cd_count = []
for i in range(N):
    for j in range(N):
        if sort_ab[i][1] < sort_cd[i][1]:
            idx_ab = sort_ab[i][0]
            idx_cd = sort_cd[i][0]
            if idx_ab not in ab_count and idx_cd not in cd_count and ab[idx_ab] < cd[idx_cd]:
                count += 1
                ab_count.append(idx_ab)
                cd_count.append(idx_cd)
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
reds = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0], reverse=False)
blues = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0], reverse=True)

# print('blues:',blues)
for i in range(n):#bluesのindex
    idx = n
    dis = 999999
    # print('reds:',reds)
    for j in range(len(reds)):#redsのindex
        if blues[i][0]<=reds[j][0]:
            break
        if blues[i][1]>reds[j][1] and sum(np.array(blues[i])-np.array(reds[j]))<=dis:#disが最小化つxが最大
            dis = sum(np.array(blues[i])-np.array(reds[j]))
            # print('dis:{},i:{},j:{}'.format(dis,i,j))
            idx = j
    if idx!=n:
        reds.pop(idx)
print(n-len(reds))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
reds = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0], reverse=False)
blues = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0], reverse=True)
ans=0
for i in range(n):#bluesのindex
    idx = n
    dis = 999999
    for j in range(len(reds)):#redsのindex
        if blues[i][0]<=reds[j][0]:
            break
        if blues[i][1]>reds[j][1] and sum(np.array(blues[i])-np.array(reds[j]))<dis:
            dis = sum(np.array(blues[i])-np.array(reds[j]))
            idx = j
    if idx!=n:
        reds.pop(idx)
print(n-len(reds))

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[1])
CD = sorted([list(map(int,input().split())) for _ in range(N)])

cnt = 0
for a, b in AB:
  for c, d in CD:
    if(a < c and b < d):
      cnt += 1
      AB.remove([a,b])
      break
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = sorted([list(map(int,input().split())) for _ in range(N)])
CD = sorted([list(map(int,input().split())) for _ in range(N)])
pare = {}
for a, b in AB[::-1]:
  for c, d in CD[::-1]:
    if(a < c and b < d):
      if((c,d) not in pare):
        pare[(c,d)] = a, b
        break
      else:
        pass
print(len(pare))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
red = [tuple(map(int, input().split())) for _ in range(N)]
blu = [tuple(map(int, input().split())) for _ in range(N)]

red.sort(key=lambda x:x[1], reverse=True)
blu.sort(key=lambda x:x[0])

pairs = []
for b in blu:
    for r in red:
        if r[0] < b[0] and r[1] < b[1] and not r in pairs:
            pairs.append(r)

print(len(pairs))

Submission status: Wrong Answer

Solution code:
n = int(input())
red = []
blue = []
for i in range(n):
    a,b = map(int,input().split())
    red.append((a,b))
for i in range(n):
    c,d = map(int,input().split())
    blue.append((c,d))
red_sorted = sorted(red)
blue_sorted = sorted(blue,key=lambda x: x[1])

count = 0
check = []
for i in red_sorted:
    for j,k in enumerate(blue_sorted):
        if (i[0] < k[0]) and (i[1] < k[1]):
            blue_sorted.pop(j)
            count += 1
            break
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = []
blue = []
for i in range(n):
    a,b = map(int,input().split())
    red.append((a,b))
for i in range(n):
    c,d = map(int,input().split())
    blue.append((c,d))
    
red_sorted = sorted(red)
blue_sorted = sorted(blue)

count = 0
check = []
for i in red_sorted:
    for j,k in enumerate(blue_sorted):
        if (i[0] < k[0]) and (i[1] < k[1]):
            blue_sorted.pop(j)
            count += 1
            break
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
r = sorted([list(map(int, input().split())) for i in range(n)], reverse=True)
b = sorted([list(map(int, input().split())) for i in range(n)])

rd = set()

for i in range(n):
    for j in range(n):
        if j in rd:
            continue
        if b[i][0] > r[j][0] and b[i][1] > r[j][1]:
            rd.add(j)
            break
print(len(rd))

Submission status: Wrong Answer

Solution code:
n = int(input())

redPoints = []
bluePoints = []

for i in range(n):
    redPoints.append([int(x) for x in input().split(" ")])
for i in range(n):
    bluePoints.append([int(x) for x in input().split(" ")])
# deletation
for bluePoint in bluePoints:
    if bluePoint[0] == 0 or bluePoint[1] == 0:
        bluePoints.remove(bluePoint)

result = 0

for bluePoint in bluePoints:
    for redPoint in redPoints:
        # print("See:", redPoint, bluePoint)
        if redPoint[0] < bluePoint[0] and redPoint[1] < bluePoint[1]:
            result += 1
            redPoints.remove(redPoint)
            # print(redPoint, " is inner of ", bluePoint)
            break

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())

redPoints = []
bluePoints = []

for i in range(n):
    redPoints.append([int(x) for x in input().split(" ")])
for i in range(n):
    bluePoints.append([int(x) for x in input().split(" ")])
# deletation
for bluePoint in bluePoints:
    if bluePoint[0] == 0 or bluePoint[1] == 0:
        bluePoints.remove(bluePoint)

result = 0

for bluePoint in bluePoints:
    for redPoint in redPoints:
        # print("See:", redPoint, bluePoint)
        if redPoint[0] < bluePoint[0] and redPoint[1] < bluePoint[1]:
            result += 1
            # print(redPoint, " is inner of ", bluePoint)
            break

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = []
B = []
for _ in range(N):
    R.append(list(map(int,input().split())))
for _ in range(N):
    B.append(list(map(int,input().split())))

count = 0
R = sorted(R,reverse=True)
for r in R:
    d = N*4
    for i,b in enumerate(B):
        if r[0]<b[0] and r[1]<b[1] and b[0]-r[0]+b[1]-r[1] < d:
            d = b[0]-r[0]+b[1]-r[1]
            b_num = i
    if d != N*4:
        B.pop(b_num)
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = []
B = []
for _ in range(N):
    R.append(list(map(int,input().split())))
for _ in range(N):
    B.append(list(map(int,input().split())))

count = 0
R = sorted(R,reverse=True)
for r in R:
    d = N*4
    for i,b in enumerate(B):
        if r[0]<b[0] and r[1]<b[1] and b[0]-r[0]+b[1]-r[1] < d:
            d = b[0]-r[0]+b[1]-r[1]
            b_num = i
    if d != N*4:
        B.pop(i)
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = []
B = []
for _ in range(N):
    R.append(list(map(int,input().split())))
for _ in range(N):
    B.append(list(map(int,input().split())))

count = 0
R = sorted(R,reverse=True)
for r in R:
    d = N*4
    for i,b in enumerate(B):
        if r[0]<b[0] and r[1]<b[1] and b[0]-r[0]+b[1]-r[1] < d:
            d = b[0]-r[0]+b[1]-r[1]
            b_num = i
    if d != N*4:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = []
B = []
for i in range(N):
    r = list(map(int,input().split()))
    r.append(0)
    R.append(r)                                       
for i in range(N):
    b = list(map(int,input().split()))
    b.append(0)
    B.append(b)                                       

R.sort(key=lambda r:r[0])
B.sort(key=lambda b:b[1])

ans = 0
for b in B:
    for r in R:
        if(r[2]==1):
            continue
        elif((r[0]<b[0])and(r[1]<b[1])):
            ans += 1
            r[2]=1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = []
B = []
for i in range(N):
    r = list(map(int,input().split()))
    r.append(0)
    R.append(r)                                       
for i in range(N):
    b = list(map(int,input().split()))
    b.append(0)
    B.append(b)                                       

R.sort(key=lambda r:r[0])
B.sort(key=lambda b:b[1])

ans = 0
for b in B:
    for r in R:
        if(r[2]==1):
            continue
        if((r[0]<b[0])and(r[1]<b[1])):
            ans += 1
            r[2]=1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[1], reverse = True)
blue = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[1])

def beFriend(red, blue):
    if red[0] < blue[0] and red[1] < blue[1]:
        return 1
    else:
        return 0

res = 0

for b in blue:
    for r in [sr for sr in red if sr[0] < b[0]]:
        if beFriend(r, b):
            res += 1
            red.pop(red.index(r))
            break

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[1], reverse = True)
blue = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[1])

def beFriend(red, blue):
    if red[0] < blue[0] and red[1] < blue[1]:
        return 1
    else:
        return 0

res = 0

for r in red:
    for b in [mb for mb in blue if r[1] < mb[1]]:
        if beFriend(r, b):
            blue.pop(blue.index(b))
            res += 1
            break

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:min(x))
blue = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:min(x))

def beFriend(red, blue):
    if red[0] < blue[0] and red[1] < blue[1]:
        return 1
    else:
        return 0

res = []

for r in red:
    for b in blue:
        if b in res:
            continue
        if beFriend(r, b):
            # print('red ', r, ' blue', b)
            res.append(b)
            break

# print(len(res))
print(len(res))

Submission status: Wrong Answer

Solution code:
n=int(input())
mp=[[] for i in range(n)]
MP=[[] for i in range(n)]
for i in range(n):
  mp[i]=list(map(int,input().split()))
for j in range(n):
  MP[j]=list(map(int,input().split()))
counT=[]
for k in mp:
  ans=0
  for K in MP:
    if k[0]<K[0] and k[1]<K[1]:
      ans+=1
  counT.append(ans)
qwe=0

counT.sort()
rty=[0]+list(set(counT))
for i in rty[1::]:
  qwe+=min(counT.count(i),i-rty[rty.index(i)-1])
print(qwe)

Submission status: Wrong Answer

Solution code:
n=int(input())
mp=[[] for i in range(n)]
MP=[[] for i in range(n)]
for i in range(n):
  mp[i]=list(map(int,input().split()))
for j in range(n):
  MP[j]=list(map(int,input().split()))
counT=[]
for k in mp:
  ans=0
  for K in MP:
    if k[0]<K[0] and k[1]<K[1]:
      ans+=1
  counT.append(ans)
qwe=0
for i in range(1,n+1):
  qwe+=min(counT.count(i),i)
print(min(qwe,n-counT.count(0),max(counT)))

Submission status: Wrong Answer

Solution code:
n=int(input())
mp=[[] for i in range(n)]
MP=[[] for i in range(n)]
for i in range(n):
  mp[i]=list(map(int,input().split()))
for j in range(n):
  MP[j]=list(map(int,input().split()))
counT=[]
for k in mp:
  ans=0
  for K in MP:
    if k[0]<K[0] and k[1]<K[1]:
      ans+=1
  counT.append(ans)
qwe=0
for i in range(1,n+1):
  qwe+=min(counT.count(i),i)
print(qwe)

Submission status: Wrong Answer

Solution code:
n=int(input())
mp=[[] for i in range(n)]
MP=[[] for i in range(n)]
for i in range(n):
  mp[i]=list(map(int,input().split()))
for j in range(n):
  MP[j]=list(map(int,input().split()))
counT=[]
for k in mp:
  ans=0
  for K in MP:
    if k[0]<K[0] and k[1]<K[1]:
      ans+=1
  counT.append(ans)
qwe=0
for i in range(n):
  if counT[i]!=0:
    qwe+=1
print(min(max(counT),qwe))

Submission status: Wrong Answer

Solution code:
# encoding:utf-8

import numpy as np
import random
import copy

def select_ok(r_list,b_position):
    pass_list = []
    for i in range(len(r_list)):
        if r_list[i][0] < b_position[0] and r_list[i][1] < b_position[1]:
            pass_list.append(r_list[i])

    return pass_list



n = int(input())
r = []
b = []

for i in range(n):
    position = list(map(int, input().split()))
    r.append(position)

for i in range(n):
    position = list(map(int, input().split()))
    b.append(position)

b_sorted = sorted(b,key=lambda x:x[0])

answer = 0
for i in range(10000):
    r_2 = copy.copy(r)
    count = 0
    for i in range(n):
        # print(r)
        pass_list = select_ok(r_2,b_sorted[i])
        # pass_list_sorted = sorted(pass_list,key=lambda x:x[0])
        if count >= answer:
            break
        elif len(pass_list) > 0:
            count += 1
            delete = random.choice(pass_list)
            r_2.remove(delete)

    answer = max(count,answer)
print(answer)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8

import numpy as np
import random
import copy

def select_ok(r_list,b_position):
    pass_list = []
    for i in range(len(r_list)):
        if r_list[i][0] < b_position[0] and r_list[i][1] < b_position[1]:
            pass_list.append(r_list[i])

    return pass_list



n = int(input())
r = []
b = []

for i in range(n):
    position = list(map(int, input().split()))
    r.append(position)

for i in range(n):
    position = list(map(int, input().split()))
    b.append(position)

b_sorted = sorted(b,key=lambda x:x[0])

answer = 0
for i in range(1000):
    r_2 = copy.copy(r)
    count = 0
    for i in range(n):
        # print(r)
        pass_list = select_ok(r_2,b_sorted[i])
        # pass_list_sorted = sorted(pass_list,key=lambda x:x[0])
        if len(pass_list) > 0:
            count += 1
            delete = random.choice(pass_list)
            r_2.remove(delete)

    answer = max(count,answer)
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
Ps = [tuple(map(int, input().split())) for i in range(n)]
Qs = [tuple(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    l = [(Ps[j], j)
         for j in range(len(Ps))
         if Ps[j][0] <= Qs[i][0] and Ps[j][1] <= Qs[i][1]]
    # print(l)
    if l != []:
        E = max(l, key=(lambda e: e[0][1]))  # 条件を満たすもののうち最もy座標が大きいもの
        # print(E)
        del Ps[E[1]]
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
ab, cd = [], []

for i in range(N):
    ab.append(list(map(int, input().split())))
for i in range(N):
    cd.append(list(map(int, input().split())))
    
ab = sorted(ab, key=itemgetter(0,1), reverse=True)
cd = sorted(cd, key=itemgetter(0,1), reverse=True)

count = 0
for i in range(N):
    flag = False
    for l in range(len(ab)):
        if cd[i][0] > ab[l][0] and cd[i][1] > ab[l][1]:
            count += 1
            ab.pop(l)
            break
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
red=sorted(list(map(int,input().split())) for i in range(N))
blue=sorted(list(map(int,input().split())) for i in range(N))
count=0
for i in red:
    for n,j in enumerate(blue):
        if i[0]<j[0] and i[1]<j[1]:
            count+=1
            del blue[n]
            break
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
red=[[int(j) for j in input().split()] for i in range(N)]
blue=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in red:
    for n,j in enumerate(blue):
        if i[0]<j[0] and i[1]<j[1]:
            count+=1
            del blue[n]
            break
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
red=[[int(j) for j in input().split()] for i in range(N)]
blue=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in red:
    for n,j in enumerate(blue):
        if i<j:
            count+=1
            del blue[n]
            break
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = []
for i in range(N):
    ab.append(list(map(int,input().split())))
cd = []
for j in range(N):
    cd.append(list(map(int,input().split())))
ab.sort(reverse=True)
cd.sort()
count = 0
i = 0
for i in range(N):
    j = 0
    for j in range(N):
        if len(ab) <= j or len(cd) <= i:
            break
        elif ab[j][0] < cd[i][0] and ab[j][1] < cd[i][1]:
            count+=1
            del ab[j]
            del cd[i]
            break
        else:
            pass
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = []
for i in range(N):
    ab.append(list(map(int,input().split())))
cd = []
for j in range(N):
    cd.append(list(map(int,input().split())))
ab.sort(reverse=True)
cd.sort()
count = 0
i = 0
for i in range(N):
    j = 0
    for j in range(N):
        if len(cd) <= j:
            break
        elif ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:
            count+=1
            del cd[j]
            break
        else:
            pass
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = []
for i in range(N):
    ab.append(list(map(int,input().split())))
cd = []
for j in range(N):
    cd.append(list(map(int,input().split())))
ab.sort(reverse=True)
cd.sort(reverse=True)
count = 0
i = 0
for i in range(N):
    j = 0
    for j in range(N):
        if len(cd) <= j:
            break
        elif ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:
            count+=1
            del cd[j]
            break
        else:
            pass
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(n)]

AB = sorted(AB)
CD = sorted(CD, reverse=True, key=lambda x: x[1])

for i in range(n):
    for j in range(len(CD)):
        if AB[i][0] < CD[j][0] and AB[i][1] < CD[j][1]:
            CD.pop(j)
            break
            
print(n - len(CD))

Submission status: Wrong Answer

Solution code:
n = int(input())
AB = []
CD = []

for i in range(n):
    AB.append(list(map(int, input().split())))
    
for i in range(n):
    CD.append(list(map(int, input().split())))

AB.sort()
CD.sort(reverse=True, key=lambda x: x[1])
    
count = 0
for i in range(n):
    for j in range(len(CD)):
        if AB[i][0] < CD[j][0] and AB[i][1] < CD[j][1]:
            count += 1
            CD.pop(j)
            break
            
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
AB = []
CD = []

for i in range(n):
    AB.append(list(map(int, input().split())))
    
for i in range(n):
    CD.append(list(map(int, input().split())))

AB.sort(reverse=True, key=lambda x: x[1])
CD.sort(reverse=True, key=lambda x: x[1])
    
count = 0
for i in range(n):
    for j in range(len(CD)):
        if AB[i][0] < CD[j][0] and AB[i][1] < CD[j][1]:
            count += 1
            CD.pop(j)
            break
            
print(count)

Submission status: Wrong Answer

Solution code:
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
N = int(input())
r = [0]*N
b = [0]*N
for i in range(N):
    r[i] = [int(n) for n in input().split()]
for i in range(N):
    b[i] = [int(n) for n in input().split()]
r = sorted(r, key=lambda x: x[0])
b = sorted(b, key=lambda x: x[0])
ans0 = 0
bpaired = N-1
for i in range(N-1,-1,-1):
    for j in range(bpaired,-1,-1):
        if r[i][0] < b[j][0] and r[i][1] < b[j][1]:
            # print(r[i][0],r[i][1],b[j][0], b[j][1])
            ans0 +=1
            bpaired-=1
            break
# print(ans0)
r = sorted(r, key=lambda x: x[1])
b = sorted(b, key=lambda x: x[1])
ans1 = 0
bpaired = N-1
for i in range(N-1,-1,-1):
    for j in range(bpaired,-1,-1):
        if r[i][1] < b[j][1] and r[i][0] < b[j][0]:
            # print(r[i][0],r[i][1],b[j][0], b[j][1])
            ans1 +=1
            bpaired-=1
            break
print(max(ans0,ans1))

Submission status: Wrong Answer

Solution code:
N = int(input())
r = [0]*N
b = [0]*N
for i in range(N):
    r[i] = [int(n) for n in input().split()]
for i in range(N):
    b[i] = [int(n) for n in input().split()]
r = sorted(r, key=lambda x: x[0])
b = sorted(b, key=lambda x: x[0])
ans = 0
bpaired = N-1
for i in range(N-1,-1,-1):
    for j in range(bpaired,-1,-1):
        if r[i][0] < b[j][0] and r[i][1] < b[j][1]:
            # print(r[i][0],r[i][1],b[j][0], b[j][1])
            ans +=1
            bpaired-=1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
CD = [list(map(int, input().split())) for i in range(N)]
AB = sorted(AB, key=lambda x: x[0], reverse=True)
CD = sorted(CD, key=lambda x: x[0], reverse=True)


ans = 0
for n in range(N):
    for i, ab in enumerate(AB):
        if ab[0] <= CD[0][0] and ab[1] <= CD[0][1]:
            ans += 1
            del AB[i]
            CD = CD[1:]
            break


print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

R = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    R.append((a, b))

B = []
for i in range(N):
    c, d = [int(x) for x in input().split()]
    B.append((c, d))

R.sort(key=lambda x: x[1], reverse=True)
B.sort(key=lambda x: x[0])

ans = 0
used_idx = []
for b in B:
    idx = -1
    ma_r = (-1, -1)
    for i, r in enumerate(R):
        if b[0] > r[0]:
            if r[1] > ma_r[1] and used_idx.count(i) == 0:
                ma_r = r
                idx = i
                break
    if idx != -1:
        used_idx.append(idx)
        ans += 1
        # print("{},{}".format(b, ma_r))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

R = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    R.append((a, b))

B = []
for i in range(N):
    c, d = [int(x) for x in input().split()]
    B.append((c, d))

R.sort(key=lambda x: x[0], reverse=True)
B.sort(key=lambda x: x[1])

ans = 0
used_idx = []
for b in B:
    idx = -1
    ma_r = (-1, -1)
    for i, r in enumerate(R):
        if b[0] > r[0]:
            if r[1] > ma_r[1] and used_idx.count(i) == 0:
                ma_r = r
                idx = i
                break
    if idx != -1:
        used_idx.append(idx)
        ans += 1
        # print("{},{}".format(b, ma_r))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

# A = [[0, 0, 0] for x in range(2 * N)]
A = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    A.append((a, b, "R", 0))

for i in range(N):
    c, d = [int(x) for x in input().split()]
    A.append((c, d, "B", 0))

A.sort(key=lambda x: x[1])
A.sort(key=lambda x: x[0])

ans = 0
for i in range(N * 2):
    if A[i][2] == "R":
        for j in range(i + 1, N * 2):
            if A[j][2] == "B" and A[j][3] == 0 and A[i][1] < A[j][1]:
                ans += 1
                A[j] = (A[j][0], A[j][1], A[j][2], 1)
                break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

# A = [[0, 0, 0] for x in range(2 * N)]
A = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    A.append((a, b, "R", 0))

for i in range(N):
    c, d = [int(x) for x in input().split()]
    A.append((c, d, "B", 0))

A.sort(key=lambda x: x[1])
A.sort(key=lambda x: x[0])

ans = 0
for i in range(N * 2):
    if A[i][2] == "R":
        for j in range(i + 1, N * 2):
            if A[j][2] == "B" and A[j][3] == 0:
                ans += 1
                A[j] = (A[j][0], A[j][1], A[j][2], 1)
                break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
R = []
B = []

for i in range(n):
    a, b = map(int, input().split())
    R.append([a, b])
    
for i in range(n):
    c, d = map(int, input().split())
    B.append([c, d])
    
R.sort(reverse=True)
B.sort(reverse=True)

count = 0

for i in range(n):
    for j in range(len(R)):
        if R[j][0] < B[i][0] and R[j][1] < B[i][1]:
            count += 1
            del R[j]
            break
            
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
R = []
B = []

for i in range(n):
    a, b = map(int, input().split())
    R.append([a, b])
    
for i in range(n):
    c, d = map(int, input().split())
    B.append([c, d])
    
R.sort(reverse=True)
B.sort(reverse=True)

count = 0

for i in range(n):
    for j in range(n):
        if R[j][0] < B[i][0] and R[j][1] < B[i][1]:
            count += 1
            R[j] = [200, 200]
            break
            
print(count)