247322026-02-14 21:16:14algoproFagyasztópypy3Részben helyes 17.5/7571ms22012 KiB
# UUID: 392bff61-bafa-4047-a1bb-60ccaf86f143
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
        else:
            if j+1 < len(ot):
                if pr:
                    print(ot[j][1], ot[j+1][1])
                j+=2
            else:
                return False
    return True

lo = 0
hi = 2000
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 helyes45ms19692 KiB
subtask20/10
2Részben helyes45ms19732 KiB
3Részben helyes41ms19648 KiB
4Hibás válasz45ms19520 KiB
5Részben helyes39ms19588 KiB
6Részben helyes48ms19596 KiB
7Részben helyes46ms19640 KiB
8Részben helyes39ms19576 KiB
9Részben helyes39ms19712 KiB
10Részben helyes41ms19716 KiB
11Részben helyes45ms19680 KiB
subtask310/20
12Részben helyes46ms19524 KiB
13Részben helyes39ms19612 KiB
14Részben helyes43ms19596 KiB
15Részben helyes43ms19572 KiB
16Részben helyes39ms19672 KiB
17Részben helyes50ms21208 KiB
18Részben helyes48ms21504 KiB
19Részben helyes39ms19920 KiB
20Részben helyes57ms21464 KiB
21Részben helyes50ms21484 KiB
22Részben helyes50ms21164 KiB
23Részben helyes54ms21440 KiB
24Részben helyes61ms21468 KiB
25Részben helyes64ms21720 KiB
26Részben helyes48ms21388 KiB
27Részben helyes61ms21700 KiB
28Részben helyes67ms21660 KiB
29Részben helyes54ms21480 KiB
30Részben helyes59ms21736 KiB
31Részben helyes61ms22012 KiB
subtask47.5/15
32Részben helyes43ms19692 KiB
33Részben helyes39ms19648 KiB
34Részben helyes39ms19564 KiB
35Részben helyes48ms21164 KiB
36Részben helyes57ms21548 KiB
37Részben helyes57ms21448 KiB
38Részben helyes43ms21044 KiB
39Részben helyes39ms19932 KiB
40Részben helyes45ms21216 KiB
41Részben helyes59ms21428 KiB
42Részben helyes59ms21468 KiB
43Részben helyes57ms21876 KiB
44Részben helyes46ms19840 KiB
45Részben helyes50ms21564 KiB
46Részben helyes65ms21976 KiB
subtask50/15
47Hibás válasz48ms21204 KiB
48Hibás válasz54ms21460 KiB
49Hibás válasz48ms21320 KiB
50Részben helyes43ms21276 KiB
51Részben helyes57ms21504 KiB
52Hibás válasz45ms19928 KiB
53Hibás válasz43ms21068 KiB
54Részben helyes54ms21484 KiB
55Részben helyes46ms19860 KiB
56Részben helyes57ms21548 KiB
57Hibás válasz48ms21128 KiB
58Hibás válasz43ms21140 KiB
59Részben helyes57ms21472 KiB
60Részben helyes46ms21104 KiB
61Részben helyes39ms19704 KiB
subtask60/15
62Hibás válasz52ms21216 KiB
63Hibás válasz52ms21544 KiB
64Hibás válasz59ms21628 KiB
65Részben helyes59ms21644 KiB
66Részben helyes71ms21828 KiB
67Hibás válasz52ms21236 KiB
68Hibás válasz52ms21372 KiB
69Részben helyes48ms21464 KiB
70Hibás válasz59ms21540 KiB
71Hibás válasz68ms21676 KiB
72Részben helyes48ms21432 KiB
73Hibás válasz54ms21596 KiB
74Hibás válasz65ms21848 KiB
75Hibás válasz50ms21448 KiB
76Hibás válasz43ms21264 KiB