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())
r = []
b = []
for i in range(N):
    r.append([int(i) for i in input().split()])
 
for i in range(N):
    b.append([int(i) for i in input().split()])
 
sorted_r = sorted(r, key=lambda r:r[0], reverse=True)
sorted_b = sorted(b)
 
ans = 0
for e1 in sorted_b:
    for e2 in sorted_r:
        if e2[0] < e1[0] and e2[1] < e1[1]:
            ans += 1
            sorted_r.remove(e2)
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
r = []
b = []
for i in range(N):
    r.append([int(i) for i in input().split()])

for i in range(N):
    b.append([int(i) for i in input().split()])

print("r", r)
print("b", b)

sorted_r = sorted(r, key=lambda r:r[0], reverse=True)
sorted_b = sorted(b)
print("sorted_r", sorted_r)
print("sorted_b", sorted_b)

ans = 0
for e1 in sorted_b:
    for e2 in sorted_r:
        if e2[0] < e1[0] and e2[1] < e1[1]:
            ans += 1
            sorted_r.remove(e2)
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
r = []
b = []
for i in range(N):
    r.append([int(i) for i in input().split()])

for i in range(N):
    b.append([int(i) for i in input().split()])

#print("r", r)
#print("b", b)

sorted_r = sorted(r)
#print(sorted_r)

sorted_b = sorted(b, key=lambda b:b[0], reverse=True)
#print(sorted_b)

ans = 0
for e1 in sorted_b:
    for e2 in sorted_r:
        if e1[0] < e2[0] and e1[1] > e2[1]:
            ans += 1
            sorted_r.remove(e2)
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[int(i) for i in input().split()]for i in range(N)]
b = [[int(i) for i in input().split()]for i in range(N)]

a.sort(reverse = True)
b.sort(reverse = True)

ans = 0
for i in a:
    for j in b:
        if i[0] < j[0]:
            if i[1] < j[1]:
                ans += 1
                b.remove(j)
                break

print (ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[int(i) for i in input().split()]for i in range(N)]
b = [[int(i) for i in input().split()]for i in range(N)]

a.sort(reverse = True)
b.sort(reverse = True)

ans = 0
for i in a:
    ax = i[0]
    ay = i[1]
    for j in b:
        if ax < j[0]:
            if ay < j[1]:
                ans += 1
                b.remove(j)
                break

print (ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[int(i) for i in input().split()]for i in range(N)]
b = [[int(i) for i in input().split()]for i in range(N)]

a.sort()
b.sort()

ans = 0
for i in range(N-1,-1,-1):

    ax = a[i][0]
    ay = a[i][1]
    for j in range(N-1,-1,-1):
        if ax < b[j][0]:
            if ay < b[j][1]:
                ans += 1
                b[j][0] = b[j][1] = 0
                break

print (ans)

Submission status: Wrong Answer

Solution code:
#1. input
n = int(input())
red_list = []
blue_list = []
 
for i in range(n):
    x, y = map(int, input().split())
    red_list.append([x, y])
for i in range(n):
    x, y = map(int, input().split())
    blue_list.append([x, y])
 
#2. search
#2.1 red:descending order in y
red_list.sort(key=lambda x:(x[1], x[0]), reverse=True)
 
#2.2 blue: ascending order
blue_list.sort(key=lambda x:(x[1], x[0]), reverse=False)
 
#2.3 search a blue point such as [x_r, y_r] < [x_b, y_b]
ans = 0
for red in red_list:
    for blue in blue_list:
        if (red[0]<blue[0]) and (red[1]<blue[1]):
            blue_list.remove(blue)
            ans += 1
            break
 
 
#3. print the result
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
r = [[int(i) for i in input().split()] for i in range(n)]
b = [[int(i) for i in input().split()] for i in range(n)]
for i in r:
	i[0],i[1] = i[1],i[0]
r = sorted(r)[::-1]
answer = 0
for i in b:
	for j in r:
		if i[0]>j[1] and i[1]>j[0]:
			answer += 1
			r.remove(j)
			break
print(answer)

Submission status: Wrong Answer

Solution code:
n=int(input())
ab=[]
for _ in range(n):
    ax=list((map(int,input().split())))
    ab.append(ax)
cd=[]
for _ in range(n):
    cx=list(map(int,input().split()))
    cd.append(cx)
ans=0
ab=sorted(ab)
cd=sorted(cd,key=lambda x:x[1],reverse=True)
ans=0
for a in ab:
    for c in cd:
        if a[0]<c[0] and a[1]<c[1]:
            ans+=1
            cd.remove(c)
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ab=[]
for _ in range(n):
    ax=list((map(int,input().split())))
    ab.append(ax)
cd=[]
for _ in range(n):
    cx=list(map(int,input().split()))
    cd.append(cx)
ans=0
ab=sorted(ab)
cd=sorted(cd,key=lambda x:x[1],reverse=True)
ans=0
for a in ab:
    for c in cd:
        if a[0]<c[0] and a[1]<c[1]:
            ans+=1
            cd.remove(c)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

Red = [list(map(int, input().split())) for i in range(N)]
Blue = [list(map(int, input().split())) for i in range(N)]

Red.sort(key=lambda x:(x[0]**2+x[1]**2))
Blue.sort(key=lambda x:(x[0]**2+x[1]**2))

for r in Red[::-1]:
    for b in Blue[::-1]:
        if r[0] < b[0] and r[1] < b[1]:
            Blue.remove(b)
            break

print(N-len(Blue))

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)])

cnt = 0
for i in blue:
    for j in red:
        if i[0] > j[0] and i[1] > j[1]:
            cnt += 1
            red.remove(j)

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
red = sorted([list(map(int, input().split())) for _ in range(N)],reverse=True)
blue = sorted([list(map(int, input().split())) for _ in range(N)],reverse=True)
res = 0
for i, j in zip(red, blue):
    if i < j:
        res += 1
    else:
        break
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
red = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:-x[0])
blue = sorted([list(map(int, input().split())) for _ in range(n)])
for i in red:
    for num, j in enumerate(blue):
        if i[0] < j[0] and i[1] < j[1]:
            ans += 1
            del blue[num]
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
red = {}
blue = {}
for i in range(n):
	x, y = map(int, input().split())
	red[x] = y
for i in range(n):
	x, y = map(int, input().split())
	blue[x] = y

sortBlue = sorted(blue.items(), key=lambda x:x[0])
count = 0
for k, v in red.items():
	for i in range(len(sortBlue)):
		if k < sortBlue[i][0]:
			if v < sortBlue[i][1]:
				count += 1
				sortBlue.pop(i)
				break
print(count)

Submission status: Wrong Answer

Solution code:
# NG 15-

N = int(input())

R = []
for i in range(N):
    x, y = list(map(int, input().split()))
    R.append((x, y))

B = []
for i in range(N):
    x, y = list(map(int, input().split()))
    B.append((x, y))

R.sort(key=lambda a:a[0]**2+a[1]**2, reverse=True)
B.sort(key=lambda a:a[0]**2+a[1]**2, reverse=False)

ans = 0
for pos in B:
    x, y = pos
    for pos2 in R:
        x2, y2 = pos2
        if x2<x and y2<y:
            R.remove(pos2)
            ans += 1
            break

print(ans)

Submission status: Wrong Answer

Solution code:
def function(count, element):
    for i in range(count):
        element.append(input().split())
        
        
count = int(input())

red = []
blue = []
count_combi = 0
check = [0 for i in range(count)]

function(count, red)
function(count, blue)

red.reverse()
blue.reverse()

for i in range(len(blue)):
    for l in range(len(red)):
        if int(blue[i][0]) >= int(red[l][0]) or int(blue[i][1]) >= int(red[l][1]) and check[l] == 0:
            check[l] = 1
            count_combi += 1
            break

print(count_combi)

Submission status: Wrong Answer

Solution code:
def function(count, element):
    for i in range(count):
        element.append(input().split())
        
        
count = int(input())

red = []
blue = []
count_combi = 0
check = [0 for i in range(count)]

function(count, red)
function(count, blue)

red.reverse()
blue.reverse()

for i in range(len(blue)):
    for l in range(len(red)):
        if int(blue[i][0]) >= int(red[l][0]) and int(blue[i][1]) >= int(red[l][1]) and check[l] == 0:
            check[l] = 1
            count_combi += 1
            break

print(count_combi)

Submission status: Wrong Answer

Solution code:
N = int(input())
red = []
blue = []
for i in range(N):
    red.append(list(map(int, input().split())))

for i in range(N):
    blue.append(list(map(int, input().split())))

ans = 0
red.sort()
blue.sort()

for i in range(N):
    for j in range(len(blue)):
        if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
            ans += 1
            del blue[j]
            break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
reds = sorted(reds, key=lambda tup: tup[1], reverse=True)
#print(reds)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
#print(blues)
blues = sorted(blues, key=lambda tup: tup[0])
#print(blues)

count = 0
for b in blues:
    tmp = []
#    print(len(reds))
    for i in range(len(reds)):
        r = reds[i]
        if b[0] > r[0]:
            tmp.append(i)
            break
            
    if len(tmp) > 0:
        del reds[tmp[0]]
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
reds = sorted(reds, key=lambda tup: tup[1], reverse=True)
#print(reds)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
#print(blues)
blues = sorted(blues, key=lambda tup: tup[0])
#print(blues)

paired = []
for b in blues:
    tmp = []
    #for r in reds:
    for i in range(len(reds)):
        r = reds[i]
        if b[0] > r[0]:
            tmp.append(i)
    if len(tmp) > 0:
        paired.append(tmp[0])
        del reds[tmp[0]]

print(len(paired))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted([list(map(int,input().split())) for i in range(n)])
ans=0
for i in range(n):
    flag=0
    res=float("inf")
    for j in range(len(a)): #一番もっともなのを探す
        if b[i][0]>a[j][0]:
            if b[i][1]-a[j][1]<res:
                res=b[i][1]-a[j][1]
                ind=j
                flag=1
    if flag:
        a.pop(ind)
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
reds = sorted(reds, key=lambda tup: tup[1], reverse=True)
#print(reds)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
#print(blues)
blues = sorted(blues, key=lambda tup: tup[0])
#print(blues)

paired = []
for b in blues:
    tmp = []
    for r in reds:
        if b[0] > r[0] and r not in paired:
            tmp.append(r)
    if len(tmp) > 0:
        max_r_y = tmp[0]
        for i in range(1, len(tmp)):
            if max_r_y[1]  < tmp[i][1]:
                max_r_y = tmp[i]
        paired.append(max_r_y)

print(len(paired))

Submission status: Wrong Answer

Solution code:
n = int(input())
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
#print(reds)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
#print(blues)
blues = sorted(blues, key=lambda tup: tup[0])
#print(blues)

paired = []
for b in blues:
    tmp = []
    for r in reds:
    #for i in range(n):
    #    r = reds[i]
        if b[0] > r[0] and r not in paired:
            tmp.append(r)
    if len(tmp) > 0:
        max_r_y = tmp[0]
        for i in range(1, len(tmp)):
            if max_r_y[1]  < tmp[i][1]:
                max_r_y = tmp[i]
        paired.append(max_r_y)

print(len(paired))

Submission status: Wrong Answer

Solution code:
def function(count, element):
    for i in range(count):
        element.append(input().split())
        
        
count = int(input())

red = []
blue = []
count_combi = 0
check = [0 for i in range(count)]

function(count, red)
function(count, blue)

red.reverse()
blue.reverse()

for i in range(len(blue)):
    for l in range(len(red)):
        if int(blue[i][0]) > int(red[l][0]) and int(blue[i][1]) > int(red[l][1]) and check[l] == 0:
            check[l] = 1
            count_combi += 1
            break

print(count_combi)

Submission status: Wrong Answer

Solution code:
def function(count, element):
    for i in range(count):
        element.append(input().split())
        
        
count = int(input())

red = []
blue = []
count_combi = 0
check = [0 for i in range(count)]

function(count, red)
function(count, blue)

for i in range(len(blue)):
    for l in range(len(red)):
        if int(blue[i][0]) > int(red[l][0]) and int(blue[i][1]) > int(red[l][1]) and check[l] == 0:
            check[l] = 1
            count_combi += 1
            break

print(count_combi)

Submission status: Wrong Answer

Solution code:
def function(count, element):
    for i in range(count):
        element.append(input().split())
        
        
count = int(input())

red = []
blue = []
count_combi = 0
check = [0 for i in range(count)]

function(count, red)
function(count, blue)

for i in range(len(blue)):
    for l in range(len(red)):
        if int(blue[i][0]) > int(red[l][0]) and int(blue[i][1]) > int(red[l][1]) and check[l] == 0:
            check[l] = 1
            count_combi += 1
            break

Submission status: Wrong Answer

Solution code:
N=int(raw_input())
ab=[]
cd=[]
for i in xrange(N):
 ab.append(map(int,raw_input().split()))
for i in xrange(N):
 cd.append(map(int,raw_input().split()))
ab.sort(key=lambda x:x[1],reverse=True)
cd.sort(key=lambda x:x[1]+x[0])
for c,d in cd:
 for a,b in ab:
  if a<c and b<d:
   ab.remove([a,b])
   break
print N-len(ab)

Submission status: Wrong Answer

Solution code:
N=int(raw_input())
ab=[]
cd=[]
for i in xrange(N):
 ab.append(map(int,raw_input().split()))
for i in xrange(N):
 cd.append(map(int,raw_input().split()))
ab.sort(key=lambda x:x[1],reverse=True)
cd.sort(key=lambda x:x[0],reverse=True)
for c,d in cd:
 for a,b in ab:
  if a<c and b<d:
   ab.remove([a,b])
   break
print N-len(ab)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
N = int(input())
red = []
for i in range(N):
    red.append(list(map(int, input().split())))
blue = []
for i in range(N):
    blue.append(list(map(int, input().split())))
a = 0
while True:
    checker = False
    for i,pair in enumerate(deepcopy(red)):
        c = []
        for j,p2 in enumerate(blue):
            if pair[0]<p2[0] and pair[1]<p2[1]:
                c.append(j)
        if c == []:
            del red[i]
            break
        if len(c) == 1:
            del red[i]
            del blue[c[0]]
            a += 1
            break
    else:
        for i,pair in enumerate(deepcopy(blue)):
            c = []
            for j,p2 in enumerate(red):
                if pair[0]>p2[0] and pair[1]>p2[1]:
                    c.append(j)
            if c == []:
                del blue[i]
                break
            if len(c) == 1:
                del blue[i]
                del red[c[0]]
                a += 1
                break
        else:
            for j,p2 in enumerate(red):
                if blue[0][0]>p2[0] and blue[0][1]>p2[1]:
                    del red[j]
                    del blue[0]
                    a += 1
                    break
    if red == [] or blue == []:
        break
print(a)

Submission status: Wrong Answer

Solution code:
import time

n = int(input())
red_list = [list(map(int, input().split())) for i in range(n)]
blue_list = [list(map(int, input().split())) for i in range(n)]

result = 0

while True:
  blue_count_list = []
  for bp in blue_list:
    ok_list = [v for v in red_list if bp[0] > v[0] and bp[1] > v[1]]
    if len(ok_list) > 0:
      blue_count_list.append([bp, len(ok_list), ok_list])

  if len(blue_count_list) == 0:
    break

  sorted(blue_count_list, key=lambda x:x[1])

  result += 1
  blue_happy = blue_count_list[0][0]
  red_happy = blue_count_list[0][2][0]
  blue_list = [b for b in blue_list[:] if b[0] != blue_happy[0] or b[1] != blue_happy[1]]
  red_list = [r for r in red_list[:] if r[0] != red_happy[0] or r[1] != red_happy[1]]

print(result)

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
  N = GI()

  l = []

  for color in 'r', 'b':
    for _ in range(N):
      x, y = GIS()
      l.append((x, y, color))

  l.sort()
  rys = [0] * 200
  count = 0
  for x, y, c in l:
    if c == 'r':
      rys[y] = 1
    else:
      found = None
      for i in range(200):
        if rys[i]:
          found = i
      if found is not None:
        rys[found] = 0
        count += 1

  print(count)

main()

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.sort(reverse=True)
CD.sort()

AB_used = set()
CD_used = set()
for index_ab, ab in enumerate(AB):
    mxy = float('inf')
    i = -1
    j = -1
    if index_ab in AB_used:
        continue
    for index_cd, cd in enumerate(CD):
        if index_cd in CD_used:
            continue
        if (ab[0] < cd[0]) & (ab[1] < cd[1]) & (cd[0]+cd[1]-ab[0]-ab[1] < mxy):
            i, j = index_ab, index_cd
            mxy = cd[1]
    if (i != -1) & (j != -1):
        AB_used.add(i)
        CD_used.add(j)

print(len(AB_used))

Submission status: Wrong Answer

Solution code:
from bisect import bisect

N = int(input())
red, blue = [], []
for _ in range(N):
    red.append(tuple(int(i) for i in input().split()))
for _ in range(N):
    blue.append(tuple(int(i) for i in input().split()))
pair = []

red.sort(key=lambda x: x[0])
blue.sort(reverse=True,key=lambda x: x[0])
r = [po[0] for po in red]

for point in blue:
    mxred = bisect(r,point[0])
    re = red[:mxred]
    re.sort(reverse=True, key=lambda x: x[1])
    for i in range(len(re)):
        if re[i][1] < point[1] and re[i] not in pair:
            pair.append(re[i])
            break

print(len(pair))

Submission status: Wrong Answer

Solution code:
from bisect import bisect

N = int(input())
red, blue = [], []
for _ in range(N):
    red.append(tuple(int(i) for i in input().split()))
for _ in range(N):
    blue.append(tuple(int(i) for i in input().split()))
pair = []

red.sort(key=lambda x: x[0])
blue.sort(reverse=True,key=lambda x: x[0])
r = [po[0] for po in red]

for point in blue:
    mxred = bisect(r,point[0])
    re = red[:mxred]
    re.sort(reverse=True, key=lambda x: x[1])
    for i in range(len(re)):
        if re[i][1] < point[1] and re[i] not in pair:
            pair.append(re[i])
            print(re[i],point)
            break

print(len(pair))

Submission status: Wrong Answer

Solution code:
#coding=utf-8

def solve(abs, cds):
    abs = sorted(abs, key = lambda x: -1 * x[1]) #sorted by y
    cds = sorted(cds, key = lambda x: x[0]) #sorted by x 

    count = 0
    for r in cds:
        print(r)
        _abs = list(filter(lambda x: r[0] > x[0] and r[1] > x[1], abs))
        if len(_abs) == 0:
            continue
        del abs[abs.index(_abs[0])]
        count += 1
    return count

if __name__ == '__main__':
    N = int(input())
    abs = []
    cds = []
    for _ in range(N):
        abs = abs + [list(map(lambda x: int(x), input().split()))] 
    for _ in range(N):
        cds = cds + [list(map(lambda x: int(x), input().split()))] 

    print(solve(abs, cds))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    N = int(input())
    red = [list(map(int, input().split())) for i in range(N)]
    blue = [list(map(int, input().split())) for i in range(N)]
    red = sorted(red)
    blue = sorted(blue)
    pair = 0

    for r in red:
        for b in blue:
            if r[0] < b[0] and r[1] < b[1]:
                pair += 1
                blue.remove(b)
                break

    print(pair)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    N = int(input())
    red = [list(map(int, input().split())) for i in range(N)]
    blue = [list(map(int, input().split())) for i in range(N)]
    red = sorted(red)
    blue = sorted(blue)
    pair = 0

    for r in red:
        for b in blue:
            if r[0] < b[0] and r[1] < b[1]:
                pair = pair + 1
                blue.remove(b)

    print(pair)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
red=[2*N]*(2*N)
blue=[-1]*(2*N)

for i in range(N):
    x=list(map(int,input().split()))
    red[x[0]]=x[1]
for i in range(N):
    x=list(map(int,input().split()))
    blue[x[0]]=x[1]


count=0
for i in range(1,2*N):
    for j in range(blue[i]-1,-1,-1):
        if j in red and red.index(j)<i:
            count+=1
            red[red.index(j)]=2*N
            blue[i]=-1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = ["0"]*2*n
red = [[0 for i in range(2)] for i in range(n)]
blue = [[0 for i in range(2)] for i in range(n)]
count = 0

for i in range(n):
    data[i] = input()
    data[i] = data[i].split(" ")
    red[i][0] = int(data[i][0])
    red[i][1] = int(data[i][1])
for i in range(n,2*n):
    data[i] = input()
    data[i] = data[i].split(" ")
    blue[i-n][0] = int(data[i][0])
    blue[i-n][1] = int(data[i][1])
red.sort(key = lambda x:x[1])
blue.sort(key = lambda x:x[0])

for i in range(n):
    for j in range(n):
        if blue[i][0] > red[j][0] and blue[i][0] > red[j][0] and red[j][0] >= 0:
            count += 1
            red[j][0] = -1
            break
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
d={}
count=0

for _ in range(n):
    a.append(list(map(int,input().split(" "))))
for _ in range(n):
    tmp=list(map(int,input().split(" ")))
    b.append(tmp)

while True:
    #print(a)
    #print(b)
    d={}
    for k in b:
        d[str(k)]=0
        #d[k]=0
        for j in a:
            if j[0]<k[0] and j[1]<k[1]:
                d[str(k)]+=1

    #print(d)
    #最小より小さいものを抽出
    out=""
    for key,value in sorted(d.items(), key=lambda x: x[1]):#[0]
        if value>0:
            out=key
            for n,k in enumerate(b):
                #print("aaa",k,out)
                if out==str(k):
                    b.pop(n)
            break

    #out=sorted(d.items(), key=lambda x: x[1])[0]
    if out=="":
        print(count)
        exit()
    else:
        #print(out.split(","))
        tmp=out.split(",")
        out1=int(tmp[0].split("[")[1])
        out2=int(tmp[1].split("]")[0])

    #exit_flag=1
    for n,i in enumerate(a):
        if i[0]<out1 and i[1]<out2:
            count+=1
            #print(a)
            #print(n)
            a.pop(n)
            #print(a)

            #exit_flag=0
            break

    #if exit_flag==1:
    #    break

#print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
d={}
count=0

for _ in range(n):
    a.append(list(map(int,input().split(" "))))
for _ in range(n):
    tmp=list(map(int,input().split(" ")))
    b.append(tmp)

while True:
    print(a)
    print(b)
    d={}
    for k in b:
        d[str(k)]=0
        #d[k]=0
        for j in a:
            if j[0]<k[0] and j[1]<k[1]:
                d[str(k)]+=1

    #print(d)
    #最小より小さいものを抽出
    out=""
    for key,value in sorted(d.items(), key=lambda x: x[1]):#[0]
        if value>0:
            out=key
            for n,k in enumerate(b):
                #print("aaa",k,out)
                if out==str(k):
                    b.pop(n)
            break

    #out=sorted(d.items(), key=lambda x: x[1])[0]
    if out=="":
        print(count)
        exit()
    else:
        #print(out.split(","))
        tmp=out.split(",")
        out1=int(tmp[0].split("[")[1])
        out2=int(tmp[1].split("]")[0])

    #exit_flag=1
    for n,i in enumerate(a):
        if i[0]<out1 and i[1]<out2:
            count+=1
            #print(a)
            #print(n)
            a.pop(n)
            #print(a)

            #exit_flag=0
            break

    #if exit_flag==1:
    #    break

#print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
d={}
count=0

for _ in range(n):
    a.append(list(map(int,input().split(" "))))
for _ in range(n):
    tmp=list(map(int,input().split(" ")))
    b.append(tmp)

while True:
    #print(a)
    #print(b)
    d={}
    for k in b:
        d[str(k)]=0
        #d[k]=0
        for j in a:
            if j[0]<k[0] and j[1]<k[1]:
                d[str(k)]+=1

    #print(d)
    #最小より小さいものを抽出
    out=""
    for key,value in sorted(d.items(), key=lambda x: x[1]):#[0]
        if value>0:
            out=key
            for n,k in enumerate(b):
                #print("aaa",k,out)
                if out==str(k):
                    b.pop(n)
            break

    #out=sorted(d.items(), key=lambda x: x[1])[0]
    if out=="":
        print(count)
        exit()
    else:
        #print(out.split(","))
        tmp=out.split(",")
        out1=int(tmp[0].split("[")[1])
        out2=int(tmp[1].split("]")[0])

    exit_flag=1
    for n,i in enumerate(a):
        if i[0]<out1 and i[1]<out2:
            count+=1
            #print(a)
            #print(n)
            a.pop(n)
            #print(a)

            exit_flag=0
            break

    if exit_flag==1:
        break

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
d={}
count=0

for _ in range(n):
    a.append(list(map(int,input().split(" "))))
for _ in range(n):
    tmp=list(map(int,input().split(" ")))
    b.append(tmp)

while True:
    #print(a)
    #print(b)
    d={}
    for k in b:
        d[str(k)]=0
        #d[k]=0
        for j in a:
            if j[0]<k[0] and j[1]<k[1]:
                d[str(k)]+=1

    #print(d)
    #最小より小さいものを抽出
    out=""
    for key,value in sorted(d.items(), key=lambda x: x[1]):#[0]
        if value>0:
            out=key
            for n,k in enumerate(b):
                #print("aaa",k,out)
                if out==str(k):
                    b.pop(n)
            break

    #out=sorted(d.items(), key=lambda x: x[1])[0]
    if out=="":
        #print(count)
        exit()
    else:
        #print(out.split(","))
        tmp=out.split(",")
        out1=int(tmp[0].split("[")[1])
        out2=int(tmp[1].split("]")[0])

    exit_flag=1
    for n,i in enumerate(a):
        if i[0]<out1 and i[1]<out2:
            count+=1
            #print(a)
            #print(n)
            a.pop(n)
            #print(a)

            exit_flag=0
            break

    if exit_flag==1:
        break

print(count)

Submission status: Wrong Answer

Solution code:
red_p = []
blue_p = []
count = 0
n = int(input())
for i in range(n):
    a_ad, b_ad = map(int, input().split())
    red_p.append((a_ad, b_ad))
for i in range(n):
    c_ad, d_ad = map(int, input().split())
    blue_p.append((c_ad, d_ad))
red_p.sort(key = lambda x: x[1])
blue_p.sort()
for i in range(n):
    l = len(red_p)
    for k in range(l):
        if red_p[k][0] < blue_p[i][0] and red_p[k][1] < blue_p[i][1]:
            count += 1
            red_p = red_p[:k] + red_p[k+1:]
            break
print(count)

Submission status: Wrong Answer

Solution code:
red_p = []
blue_p = []
count = 0
n = int(input())
for i in range(n):
    a_ad, b_ad = map(int, input().split())
    red_p.append((a_ad, b_ad))
for i in range(n):
    c_ad, d_ad = map(int, input().split())
    blue_p.append((c_ad, d_ad))
red_p.sort()
blue_p.sort(key = lambda x: x[1])
for i in range(n):
    l = len(blue_p)
    for k in range(l):
        if red_p[i][0] < blue_p[k][0] and red_p[i][1] < blue_p[k][1]:
            count += 1
            blue_p = blue_p[:k] + blue_p[k+1:]
            break
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    b.append(list(map(int,input().split())))
an=sorted(a,reverse=True)
bn=sorted(b)#, key=lambda x:(x[0],x[1]))
count=0
for i in range(len(bn)):
    for j in range(len(an)):
#        print(an[j],bn[i])
        if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]:
            count+=1
            an.pop(j)
            break
 
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = 0
x = []
y = []

for i in range(N):
    s,t = map(int, input().split())
    x.append([s,t])

for j in range(N):
    u,v = map(int, input().split())
    y.append([v,u])

x.reverse()
y.sort()
k = 0
while k < N:
    for l in range(len(x)):
        if x[l][0]<y[k][1] and x[l][1]<y[k][0]:
            a += 1
            del(x[l])
            break
    k += 1

print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = 0
x = []
y = []

for i in range(N):
    s,t = map(int, input().split())
    x.append([s,t])

for j in range(N):
    u,v = map(int, input().split())
    y.append([v,u])

x.reverse()
y.sort()

for k in range(N):
    for l in range(len(x)):
        if x[l][0]<y[k][1] and x[l][1]<y[k][0]:
            a += 1
            del(x[l])
            break

print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = 0
x = []
y = []

for i in range(N):
    s,t = map(int, input().split())
    x.append([s,t])

for j in range(N):
    u,v = map(int, input().split())
    y.append([v,u])

x.reverse()
y.sort()

for k in range(N):
    for l in range(len(x)):
        if x[l][0]<y[k][1] and x[l][1]<y[k][0]:
            a += 1
            x.pop(l)
            break

print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = 0
x = []
y = []

for i in range(N):
    s,t = map(int, input().split())
    x.append([s,t])

for j in range(N):
    u,v = map(int, input().split())
    y.append([v,u])

x.sort()
y.reverse()

for k in range(N):
    for l in range(len(x)):
        if x[l][0]<y[k][1] and x[l][1]<y[k][0]:
            a += 1
            x.pop(l)
            break

print(a)