247332026-02-14 21:18:57algoproFagyasztópypy3Részben helyes 17.5/7570ms22060 KiB
# UUID: 6591267a-a075-474d-b369-428926e83c95
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**6)

N = int(input())
negy=[]
ot=[]
for i in range(1,N+1):
    S, M = map(int,input().split())
    if M==4: 
        negy.append((S,i))
    elif M>4:
        ot.append((S,i))

negy.sort()
ot.sort()

def test(k, pr=False):
    i=j=0
    for day in range(1,k+1):
        while i < len(negy) and negy[i][0] < day:
            i += 1
        while j < len(ot) and ot[j][0] < day:
            j += 1
        if i < len(negy):
            if j < len(ot):
                if pr:
                    print(negy[i][1], ot[j][1])
                i += 1
                j += 1
            else:
                return False
        elif j+1 < len(ot):
            if pr:
                print(ot[j][1], ot[j+1][1])
            j+=2
        else:
            return False
    return True

lo = 0
hi = 2001
while hi-lo > 1:
    mid = (hi+lo)//2
    if test(mid):
        lo = mid
    else:
        hi = mid
print(lo)
#test(lo,True)
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Részben helyes39ms19692 KiB
subtask20/10
2Részben helyes39ms19692 KiB
3Részben helyes45ms19648 KiB
4Hibás válasz45ms19568 KiB
5Részben helyes39ms19680 KiB
6Részben helyes39ms19692 KiB
7Részben helyes46ms19728 KiB
8Részben helyes45ms19668 KiB
9Részben helyes39ms19656 KiB
10Részben helyes43ms19504 KiB
11Részben helyes39ms19728 KiB
subtask310/20
12Részben helyes45ms19544 KiB
13Részben helyes45ms19672 KiB
14Részben helyes45ms19756 KiB
15Részben helyes41ms19676 KiB
16Részben helyes41ms19688 KiB
17Részben helyes50ms21100 KiB
18Részben helyes54ms21560 KiB
19Részben helyes41ms19892 KiB
20Részben helyes50ms21528 KiB
21Részben helyes50ms21432 KiB
22Részben helyes50ms21264 KiB
23Részben helyes61ms21532 KiB
24Részben helyes54ms21476 KiB
25Részben helyes64ms21832 KiB
26Részben helyes54ms21404 KiB
27Részben helyes63ms21728 KiB
28Részben helyes65ms21724 KiB
29Részben helyes52ms21456 KiB
30Részben helyes57ms21624 KiB
31Részben helyes61ms21816 KiB
subtask47.5/15
32Részben helyes39ms19688 KiB
33Részben helyes43ms19680 KiB
34Részben helyes39ms19736 KiB
35Részben helyes48ms21220 KiB
36Részben helyes57ms21504 KiB
37Részben helyes57ms21364 KiB
38Részben helyes43ms21096 KiB
39Részben helyes39ms19904 KiB
40Részben helyes50ms21108 KiB
41Részben helyes52ms21452 KiB
42Részben helyes57ms21440 KiB
43Részben helyes56ms21736 KiB
44Részben helyes45ms19744 KiB
45Részben helyes50ms21592 KiB
46Részben helyes67ms22060 KiB
subtask50/15
47Hibás válasz48ms21040 KiB
48Hibás válasz50ms21380 KiB
49Hibás válasz50ms21484 KiB
50Részben helyes48ms21144 KiB
51Részben helyes48ms21452 KiB
52Hibás válasz41ms19912 KiB
53Hibás válasz48ms21232 KiB
54Részben helyes54ms21392 KiB
55Részben helyes39ms19692 KiB
56Részben helyes50ms21468 KiB
57Hibás válasz48ms21112 KiB
58Hibás válasz48ms21064 KiB
59Részben helyes57ms21532 KiB
60Részben helyes48ms21040 KiB
61Részben helyes39ms19764 KiB
subtask60/15
62Hibás válasz50ms21124 KiB
63Hibás válasz52ms21408 KiB
64Hibás válasz59ms21668 KiB
65Részben helyes64ms21660 KiB
66Részben helyes70ms21716 KiB
67Hibás válasz45ms21216 KiB
68Hibás válasz59ms21468 KiB
69Részben helyes48ms21468 KiB
70Hibás válasz52ms21468 KiB
71Hibás válasz57ms21904 KiB
72Részben helyes48ms21468 KiB
73Hibás válasz61ms21540 KiB
74Hibás válasz54ms21720 KiB
75Hibás válasz57ms21548 KiB
76Hibás válasz48ms21220 KiB