Problem:


Score : 400 points

Problem Statement

Joisino is planning to record N TV programs with recorders.

The TV can receive C channels numbered 1 through C.

The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.

Here, there will never be more than one program that are broadcast on the same channel at the same time.

When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).

Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.

Constraints

1≤N≤10^5

1≤C≤30

1≤s_i<t_i≤10^5

1≤c_i≤C

If c_i=c_j and i≠j, either t_i≤s_j or s_i≥t_j.

All input values are integers.

Input

Input is given from Standard Input in the following format:

N C
s_1 t_1 c_1
:
s_N t_N c_N

Output

When the minimum required number of recorders is x, print the value of x.

Sample Input 1

3 2
1 7 2
7 8 1
8 12 1

Sample Output 1

2

Two recorders can record all the programs, for example, as follows:

With the first recorder, record Channel 2 from time 1 to time 7. The first program will be recorded. Note that this recorder will be unable to record other channels from time 0.5 to time 7.

With the second recorder, record Channel 1 from time 7 to time 12. The second and third programs will be recorded. Note that this recorder will be unable to record other channels from time 6.5 to time 12.

Sample Input 2

3 4
1 3 2
3 4 4
1 4 3

Sample Output 2

3

There may be a channel where there is no program to record.

Sample Input 3

9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3

Sample Output 3

2



Sample input:
3 2
1 7 2
7 8 1
8 12 1


Sample output:
2

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
tv = [[0]*100001 for _ in range(C)]
T = [0]*C
for _ in range(N):
    s, t, c = map(int, input().split())
    c -= 1
    tv[c][s-1] += 1
    tv[c][t] -= 1
    T[c] = max(T[c], t)


# for c in range(C):
#     print(tv[c][:T[c]+1])

for c in range(C):
    for t in range(1, T[c]+1):
        tv[c][t] += tv[c][t-1]

# for c in range(C):
#     print(tv[c][:T[c]+1])

ans = 0
for t in range(T[c]+1):
    s = 0
    for c in range(C):
        s += tv[c][t]
    ans = max(ans, s)

print(ans)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
mx_t = 0
for _ in range(n):
    x = list(map(int, input().split()))
    stc.append(x)
    mx_t = max(mx_t, x[1])

ans = 0
A = [0]*(mx_t*2+1)
time_zone = [0]*(mx_t*2+1)
for cc in range(c+1): # cc:candidate c [0,c]
    for s,t,ci in stc:
        if ci == cc:
            time_zone[2*s-1] += 1
            time_zone[2*t] -= 1
for j in range(mx_t*2):
    A[j+1] += A[j] + time_zone[j+1]
    ans = max(ans, A[j+1])
# print(time_zone)
# print(A)
# print('---')
print(ans)

# print('==============')
# print(n,c)
# print(*stc, sep='\n')
# print('mx_t',mx_t)
# print(time_zone)
# print(A)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
mx_t = 0
for _ in range(n):
    x = list(map(int, input().split()))
    stc.append(x)
    mx_t = max(mx_t, x[1])

time_zone = [0]*(mx_t+1+1)*2
for s,t,c in stc:
    time_zone[2*s-1] += 1
    time_zone[2*t] -= 1

A = [0]*(mx_t+1+1)*2
# A[0] = time_zone[0]
for i in range(mx_t*2+1):
    A[i+1] = A[i] + time_zone[i+1]

ans = max(A)
print(ans)

# print('==============')
# print(n,c)
# print(*stc, sep='\n')
# print('mx_t',mx_t)
# print(time_zone)
# print(A)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
mx_t = 0
for _ in range(n):
    x = list(map(int, input().split()))
    stc.append(x)
    mx_t = max(mx_t, x[1])

time_zone = [0]*(mx_t+1+1)
for s,t,c in stc:
    time_zone[s-1] += 1
    time_zone[t] -= 1
    # time_zone[s] += 1
    # time_zone[t+1] -= 1

# A = [0]*(mx_t+1+1)
# for i in range(mx_t+1):
#     A[i+1] = A[i] + time_zone[i+1]

A = [0]*(mx_t+1+1)
A[0] = time_zone[0]
for i in range(mx_t+1):
    A[i+1] = A[i] + time_zone[i+1]

ans = max(A)
print(ans)

# print('==============')
# print(n,c)
# print(*stc, sep='\n')
# print('mx_t',mx_t)
# print(time_zone)
# print(A)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
mx_t = 0
for _ in range(n):
    x = list(map(int, input().split()))
    stc.append(x)
    mx_t = max(mx_t, x[1])
# print(n,c)
# print(*stc, sep='\n')
# print('mx_t',mx_t)

time_zone = [0]*(mx_t+1+10)
for s,t,c in stc:
    time_zone[s] += 1
    time_zone[t+1] -= 1

# print(time_zone)

A = [0]*(mx_t+1+10)
for i in range(mx_t+5):
    A[i+1] = A[i] + time_zone[i+1]

# print(A)
ans = -1
# print(max(A))
# print(A[:mx_t+1])
print(max(A[:mx_t+1]))
# for a in A[:mx_t]:
#     ans = max(ans, a)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
mx_t = 0
for _ in range(n):
    x = list(map(int, input().split()))
    stc.append(x)
    mx_t = max(mx_t, x[1])
# print(n,c)
# print(*stc, sep='\n')
# print('mx_t',mx_t)

time_zone = [0]*(mx_t+1+10)
for s,t,c in stc:
    time_zone[s] += 1
    time_zone[t+1] -= 1

# print(time_zone)

A = [0]*(mx_t+1+10)
for i in range(mx_t+5):
    A[i+1] = A[i] + time_zone[i+1]

# print(A)
print(max(A))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
mx_t = 0
for _ in range(n):
    x = list(map(int, input().split()))
    stc.append(x)
    mx_t = max(mx_t, x[1])
# print(n,c)
# print(*stc, sep='\n')
# print('mx_t',mx_t)

time_zone = [0]*(mx_t+1+1)
for s,t,c in stc:
    time_zone[s] += 1
    time_zone[t+1] -= 1

# print(time_zone)

A = [0]*(mx_t+1+1)
for i in range(mx_t):
    A[i+1] = A[i] + time_zone[i+1]

# print(A)
print(max(A))

Submission status: Wrong Answer

Solution code:
n,C=map(int,input().split())
dp=[0 for i in range(100010)]
for i in range(n):
  s,t,c=map(int,input().split())
  t+=1
  dp[s]+=1
  dp[t]-=1
for i in range(1,100010):
  dp[i]+=dp[i-1]
print(max(dp))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())

old=[[] for i in range(C)]

for i in range(N):
    s,t,c=map(int,input().split())
    old[c-1].append((s,t))
ch=[]
for i in range(C):
    old[i].sort()
    j=0
    while(j<len(old[i])):
        if j<len(old[i])-1 and old[i][j][1]==old[i][j+1][0]:
            ch.append(((old[i][j][0]-1)*2+1,old[i][j+1][1]*2))
            j+=2
        else:
            ch.append(((old[i][j][0]-1)*2+1,old[i][j][1]*2))
            j+=1
imos=[0]*(2*10**5+10)
for s,t in ch:
    imos[s]+=1
    imos[t]-=1
ans=0
for i in range(1,2*10**5+10):
    imos[i]=imos[i-1]+imos[i]
    ans=max(ans,imos[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())

old=[[] for i in range(C)]

for i in range(N):
    s,t,c=map(int,input().split())
    old[c-1].append((s,t))
ch=[]
for i in range(C):
    old[i].sort()
    j=0
    while(j<len(old[i])):
        if j<len(old[i])-1 and old[i][j][1]==old[i][j+1][0]:
            ch.append((old[i][j][0],old[i][j+1][1]))
            j+=2
        else:
            ch.append(old[i][j])
            j+=1
imos=[0]*(2*10**5+10)
for s,t in ch:
    imos[s-1]+=1
    imos[t]-=1
ans=0
for i in range(1,2*10**5+10):
    imos[i]=imos[i-1]+imos[i]
    ans=max(ans,imos[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
imos=[0]*(2*10**5+10)

for i in range(N):
    s,t,c=map(int,input().split())
    imos[((s-1)*2)+1]+=1
    imos[t*2]-=1

for i in range(1,2*10**5+10):
    imos[i]=imos[i-1]+imos[i]
ans=0
for i in imos:
    ans=max(ans,i)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
imos=[0]*(10**5+2)

for i in range(N):
    s,t,c=map(int,input().split())
    imos[s-1]+=1
    imos[t]-=1
for i in range(1,10**5+2):
    imos[i]=imos[i]+imos[i-1]
ans=0
for i in range(10**5+2):
    ans=max(ans,imos[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools

N,C = map(int,input().split())

time = [[0]*(10**5+1) for _ in range(C)]

for _ in range(N):
    s, t, c = map(lambda x:int(x)-1,input().split())
    time[c-1][s] += 1
    time[c-1][t+1] -= 1
    

cumsum = []
for i in range(C):
    cumsum.append(list(itertools.accumulate(time[i])))

#print(cumsum)

cs = np.sum(cumsum, axis=0)

print(max(cs))

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools

N,C = map(int,input().split())

time = [[0]*(10**5+2) for _ in range(C)]

for _ in range(N):
    s, t, c = map(int,input().split())
    time[c-1][s-1] += 1
    time[c-1][t] -= 1

cumsum = []
for i in range(C):
    cumsum.append(list(itertools.accumulate(time[i])))

#print(cumsum)

cs = np.sum(cumsum, axis=0)

print(max(cs))

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools

N,C = map(int,input().split())

time = [[0]*(10**5+2) for _ in range(C)]

for _ in range(N):
    s, t, c = map(int,input().split())
    time[c-1][s] += 1
    time[c-1][t+1] -= 1

cumsum = []
for i in range(C):
    cumsum.append(list(itertools.accumulate(time[i])))

#print(cumsum)

cs = np.sum(cumsum, axis=0)

print(max(cs))

Submission status: Wrong Answer

Solution code:
import itertools

N,C = map(int,input().split())

time = [0]*(10**5+2)
for _ in range(N):
    s, t, c = map(int,input().split())
    time[s] += 1
    time[t+1] -= 1
    
cumsum = list(itertools.accumulate(time))
#print(cumsum)

print(max(cumsum))

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = np.array([[0]*(10**5+1) for i in range(C+1)])

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c, s - 1:t] = 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s-1] += 1
    imos[c][t] -= 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(max(0,ans))

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s-1] += 1
    imos[c][t] -= 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s-1] += 1
    imos[c][t-1] -= 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s-1] += 1
    if t <= 10**5:
        imos[c][t] -= 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+1) for i in range(C+1)]

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s] += 1
    if t <= 10**5-1:
        imos[c][t+1] -= 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos, axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N,C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+2) for i in range(C+1)]
 
for i in range(N):
    s,t,c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s] += 1
    imos[c][t+1] -= 1
 
imos = np.array(imos)[:,:-1]
#print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos,axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
# 1-index
from sys import stdin
import numpy as np
N,C = [int(x) for x in stdin.readline().rstrip().split()]
imos = [[0]*(10**5+2) for i in range(C+1)]
 
for i in range(N):
    s,t,c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c][s] += 1
    imos[c][t+1] -= 1
 
imos = np.array(imos)
#print(np.cumsum(imos,axis=1))
ans = max(np.cumsum(imos,axis=1).sum(axis=0))
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [0]*int(2*1e5+20)
for i in range(N):
    imos[s[i]*2-1]+=1
    imos[t[i]*2]-=1

ans = 0
for i in range(1,int(2*1e5+10)):
    imos[i]=imos[i-1]+imos[i]
    ans = max(ans,imos[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [0]*int(1e5+20)
for i in range(N):
    imos[s[i]]+=1
    imos[t[i]+1]-=1

ans = 0
for i in range(1,int(1e5+10)):
    imos[i]=imos[i-1]+imos[i]
    ans = max(ans,imos[i])
print(ans)

Submission status: Wrong Answer

Solution code:
# heapqの方針で上手くいかなかった
# 解説放送を見てimosにした

def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R > other.R  # heapqで大きい方から出すため逆で定義

    N, C = map(int, input().split())
    ps = [[] for _ in range(30)]
    for _ in range(N):
        l, r, ch = map(int, input().split())
        heappush(ps[ch - 1], Prog(l, r))

    imos = [0] * (10 ** 5 + 1)
    for ps_ch in ps:
        while ps_ch:
            l, r = heappop(ps_ch)
            while ps_ch and ps_ch[0].L == r:
                r = ps_ch[0].R
                heappop(ps_ch)
            else:
                imos[l - 1] += 1
                imos[r] -= 1

    ans = imos[0]
    for i in range(10 ** 5):
        imos[i + 1] += imos[i]
        ans = max(ans, imos[i + 1])

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())

st = [0] * 100002
for i in range(N):
  s, t, c = map(int, input().split())
  st[s] += 1
  st[t+1] -= 1
  
for i in range(len(st)-1):
  st[i+1] += st[i]
  
print(max(st))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.zeros((C, 10**5+2),dtype="int")

for i in range(N):
    s,t,c=map(int, input().split())
    L[c-1,s-1]+=1
    L[c-1,t]-=1

for i in range(1,L.shape[1]):
    L[:,i]+=L[:,i-1]

print(max(np.sum(L,axis=0)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.zeros((C, 10**5+2),dtype="int")

for i in range(N):
    s,t,c=map(int, input().split())
    L[c-1,s-1]+=1
    L[c-1,t]-=1

L=np.cumsum(L, axis=1)
print(max(np.sum(L,axis=0)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.zeros((C, 10**5+2),dtype="int")

for i in range(N):
    s,t,c=map(int, input().split())
    L[c-1,s-1]+=1
    L[c-1,t]-=1

L=np.cumsum(L, axis=1)
print(int(L.sum(axis=0).max()))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.ones((C, 10**5+2))*0

for i in range(N):
    s,t,c=map(int, input().split())
    L[c-1,s-1]+=1
    L[c-1,t]-=1

L=np.cumsum(L, axis=1)
print(int(L.sum(axis=0).max()))

Submission status: Wrong Answer

Solution code:
def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R ch')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R > other.R  # heapqで大きい方から出すため逆で定義

    N, C = map(int, input().split())
    ps = []
    for _ in range(N):
        p = Prog(*map(int, input().split()))
        ps.append(p)
    ps.sort(key=attrgetter('R'))

    rec = []
    for p in ps:
        tank = []
        while rec:
            if p.L < rec[0].R: break
            recorder = heappop(rec)
            if (recorder.ch == p.ch and recorder.R <= p.L) or (recorder.R < p.L): break
            tank.append(recorder)
        for r in tank: heappush(rec, r)
        heappush(rec, p)
    print(len(rec))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.zeros((C, 10**5+2))

for i in range(N):
    s,t,c=map(int, input().split())
    L[c-1,s-1]+=1
    L[c-1,t]-=1

L=np.cumsum(L, axis=1)
print(int(L.sum(axis=0).max()))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int, input().split())

#s~tでc
L=np.zeros((C, 10**5+1))

for i in range(N):
    s,t,c=map(int, input().split())
    L[c-1,s-1]+=1
    L[c-1,t]-=1

L=np.cumsum(L, axis=1)
print(int(L.sum(axis=0).max()))

Submission status: Wrong Answer

Solution code:
def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R ch')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R < other.R

    N, C = map(int, input().split())
    ps = []
    for _ in range(N):
        p = Prog(*map(int, input().split()))
        ps.append(p)
    ps.sort(key=attrgetter('R'))

    rec = []
    for p in ps:
        tank = []
        while rec:
            if p.L < rec[0].R: break
            recorder = heappop(rec)
            if (recorder.ch == p.ch and recorder.R <= p.L) or (recorder.R < p.L): break
            tank.append(recorder)
        for r in tank: heappush(rec, r)
        heappush(rec, p)
    print(len(rec))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def binary_search(*, ok, ng, func):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok


def main():
    from collections import namedtuple
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R ch')

    N, C = map(int, input().split())
    ps = []
    for _ in range(N):
        p = Prog(*map(int, input().split()))
        ps.append(p)
    ps.sort(key=attrgetter('R'))

    def is_ok(mid, l, ch):
        return ((rec[mid].ch == ch) and (rec[mid].R <= l)) or (rec[mid].R < l)

    rec = []
    for p in ps:
        if rec:
            j = binary_search(ok=len(rec), ng=-1, func=lambda mid: is_ok(mid, p.L, p.ch))
            if j == len(rec):
                rec.append(p)
            else:
                rec[j] = p
        else:
            rec.append(p)
    print(len(rec))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
stc = [[int(i) for i in input().split()] for _ in range(N)]
stc.sort()
stc.sort(key=lambda x: x[2])
a = []
S, T, C = stc[0]
for s, t, c in stc[1:]:
    if c == C and T == S:
        T = t
    else:
        a.append((S, T, C))
        S, T, C = s, t, c
a.append((S, T, C))

a.sort(key=lambda x: x[1])
l = [a[0][1]]
for s, t, c in a[1:]:
    i = bisect_left(l, s)
    if 0 < i and l[i - 1] < s:
        l.pop(i - 1)
    l.append(t)
print(len(l))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N, C = map(int, input().split())
stc = [[int(i) for i in input().split()] for _ in range(N)]
stc.sort(key=lambda x: x[1])
l = [stc[0][1]]
for s, t, c in stc[1:]:
    i = bisect_left(l, s)
    if i == 0:
        if l[0] < s:
            l.pop(0)
    elif l[i - 1] < s:
        l.pop(i - 1)
    l.append(t)
print(len(l))

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c = map(int, input().split())
    STC = [list(map(int, input().split())) for _ in range(n)]

    imos = [0] * (10 ** 5 + 1)
    for i in range(n):
        s, t, c = STC[i]

        imos[s - 1] += 1
        imos[t] -= 1

    for i in range(1, 10 ** 5 + 1):
        imos[i] += imos[i - 1]

    print(max(imos))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import numpy as np

n,c = map(int,input().split())

li = np.zeros(10**5+1,int)

for _ in range(n):
    s,t,c = map(int,input().split())
    li[s-1:t] += 1

print(np.max(li))

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

event.sort()
used = deque()
ans = 0
for time, _, c in event:
    if c >= 0:
        if not used or time <= used[0]:
            pass
        else:
            used.popleft()
    else:
        c = ~c
        used.append(time)

print(len(used))

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c = map(int, input().split())
    STC = [list(map(int, input().split())) for _ in range(n)]

    imos = [0] * (10 ** 5 + 1)
    for i in range(n):
        s, t, c = STC[i]
        imos[s - 1] += 1
        imos[t] += 1

    for i in range(1, n):
        imos[i] += imos[i - 1]

    print(max(imos))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, C = map(int, input().split())
event = []
for _ in range(N):
    s, t, c = map(int, input().split())
    event.append((s, c))
    event.append((t, ~c))

event.sort()
used = deque()
ans = 0
for time, c in event:
    if c >= 0:
        if not used or time <= used[0]:
            pass
        else:
            used.popleft()
    else:
        c = ~c
        used.append(time)

print(len(used))

Submission status: Wrong Answer

Solution code:
def examA():
    C1 = SI()
    C2 = SI()
    ans = "YES"
    if C1[0]!=C2[2] or C1[1]!=C2[1] or C1[2]!=C2[0]:
        ans = "NO"
    print(ans)
    return

def examB():
    A, B, C, X, Y = LI()
    loop = max(X,Y)
    ans = inf
    for i in range(loop+1):
        cost = i*2*C
        if X>i:
            cost += A*(X-i)
        if Y>i:
            cost += B*(Y-i)
        ans = min(ans,cost)
    print(ans)
    return

def examC():
    def gcd(x, y):
        if y == 0:
            return x
        while (y != 0):
            x, y = y, x % y
        return x
    N, x = LI()
    X = LI()
    if N==1:
        print(abs(X[0]-x))
        return
    for i in range(N):
        X[i] = abs(X[i]-x)
    now = gcd(X[0],X[1])
    for i in range(2,N):
        now = gcd(now,X[i])
    ans = now
    print(ans)
    return

def examD():
    N = I()
    C = [LI()for _ in range(N-1)]
    ans = [inf]*N
    for i in range(N):
        cur = 0
        for j in range(i,N-1):
            c, s, f = C[j]
            next = 0
            if cur<=s:
                cur = s+c
            else:
                cur = (1+(cur-1)//f)*f + c
        ans[i] = cur
    for v in ans:
        print(v)
    return

def examE():
    class segment_():
        def __init__(self, A, n, segfunc, ide_ele=0):
            #####単位元######要設定0or1orinf
            self.ide_ele = ide_ele
            ####################
            self.num = 1 << (n - 1).bit_length()
            self.seg = [self.ide_ele] * 2 * self.num
            self.segfunc = segfunc
            # set_val
            for i in range(n):
                self.seg[i + self.num] = A[i]
                # built
            for i in range(self.num - 1, 0, -1):
                self.seg[i] = self.segfunc(self.seg[2 * i], self.seg[2 * i + 1])

        def update(self, k, r):
            k += self.num
            self.seg[k] = r
            while k:
                k >>= 1
                self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

        # 値xに1加算
        def add(self, k, x=1):
            k += self.num
            self.seg[k] += x
            while k:
                k >>= 1
                self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])

        def query(self, p, q):
            # qは含まない
            if q < p:
                return self.ide_ele
            p += self.num;
            q += self.num
            res = self.ide_ele
            while p < q:
                if p & 1 == 1:
                    res = self.segfunc(res, self.seg[p])
                    p += 1
                if q & 1 == 1:
                    q -= 1
                    res = self.segfunc(res, self.seg[q])
                p >>= 1;
                q >>= 1
            return res
    N, C = LI()
    S = defaultdict(list)
    T = 0
    for _ in range(N):
        s,t,c = LI()
        c -= 1
        T = max(t,T)
        S[c].append([s,t])
    Seg = segment_([0]*(T+1), (T+1), lambda a, b: a + b)
    for i in range(C):
        S[i].sort()
        #print(S[i])
        for s,t in S[i]:
            Seg.add(s)
            Seg.add(t+1,-1)
    ans = 0
    for j in range(T):
        cur = Seg.query(0,j+1)
        ans = max(ans,cur)
    print(ans)
    return

def examF():
    class combination():
        # 素数のmod取るときのみ　速い
        def __init__(self, n, mod):
            self.n = n
            self.mod = mod
            self.fac = [1] * (n + 1)
            self.inv = [1] * (n + 1)
            for j in range(1, n + 1):
                self.fac[j] = self.fac[j - 1] * j % mod

            self.inv[n] = pow(self.fac[n], mod - 2, mod)
            for j in range(n - 1, -1, -1):
                self.inv[j] = self.inv[j + 1] * (j + 1) % mod

        def comb(self, n, r):
            if r > n or n < 0 or r < 0:
                return 0
            return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod
    N, M, K = LI()
    B = N*M
    C = combination(B,mod)
    ans = 0
    for i in range(N):
        for j in range(M):
            if i>0 and j>0:
                ans += (i+j)*(N - i) * (M - j) * C.comb(B - 2, K-2) *2
            else:
                ans += (i+j)*(N - i) * (M - j) * C.comb(B - 2, K-2)
            ans %= mod
            #print(ans)
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
table=[0]*220000
for i in range(n):
    a,s,c=map(int,input().split())
    table[2*a-1]+=1
    table[s*2]-=1
from itertools import accumulate
print(max(list(accumulate(table))))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
table=[0]*220000
for i in range(n):
    a,s,c=map(int,input().split())
    table[a-1]+=1
    table[s]-=1
from itertools import accumulate
print(max(list(accumulate(table))))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, C = map(int,input().split())
T1 = [[] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int,input().split())
    T1[c-1].append([s,t])
for i in range(C):
    T1[i].sort()
T2 = [[] for _ in range(C)]
for i in range(C):
    for s, t in T1[i]:
        if len(T2[i]) != 0 and T2[i][-1][1] == s:
            T2[i][-1][1] = t
        else:
            T2[i].append([s,t])

print(T1)
print(T2)

L = np.zeros(10 ** 5 + 2, int)
for i in range(C):
    for time in T2[i]:
        L[time[0]] += 1
        L[time[1]+1] -= 1

print(L[:100])

ans = L.cumsum().max()

print(L.cumsum()[:100])

print(ans)

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
table = [[0]*(10**5 + 1) for i in range(C)]

for i in range(N):
  s, t, c = map(int, input().split())
  table[c-1][s-1] += 1
  table[c-1][t] -= 1

for c in range(C):
  for i in range(1, 10**5+1):
    table[c][i] += table[c][i-1]

ans = 0
for i in range(10**5 + 1):
  num = 0
  for c in range(C):
    num += table[c][i]
  ans = max(ans, num)

print(ans)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
cnt = [[0 for _ in range(c + 1)] for _ in range(10 ** 5 + 2)]
cnt_sum = [0] * (10 ** 5 + 2)
for _ in range(n):
    s, t, _c = map(int, input().split())
    cnt[s][_c] += 1
    cnt[t + 1][_c] -= 1
for i in range(10 ** 5 + 2):
    for j in range(1, c + 1):
        cnt[i][j] += cnt[i - 1][j]
cnt_sum[0] = sum(cnt[0])
for i in range(1, 10 ** 5 + 2):
    for j in range(1, c + 1):
        cnt_sum[i] += (cnt[i][j] >= 1)
print(max(cnt_sum))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
cnt = [[0 for _ in range(c + 1)] for _ in range(10 ** 5 + 3)]
cnt_sum = [0] * (10 ** 5 + 3)
for _ in range(n):
    s, t, _c = map(int, input().split())
    if cnt[s + 1][_c] == -1:
        cnt[t + 1][0] -= 1
        cnt[t + 1][_c] = -1
        cnt[s + 1][0] += 1
        cnt[s + 1][_c] = 0
    elif cnt[t][_c] == 1:
        cnt[s][0] += 1
        cnt[s][_c] = 1
        cnt[t][0] -= 1
        cnt[t][_c] = 0
    else:
        cnt[s][0] += 1
        cnt[s][_c] = 1
        cnt[t + 1][0] -= 1
        cnt[t + 1][_c] = -1
cnt_sum[0] = cnt[0][0]
for i in range(1, 10 ** 5 + 3):
    cnt_sum[i] = cnt_sum[i - 1] + cnt[i][0]
print(max(cnt_sum))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
cnt = [[0 for _ in range(c + 1)] for _ in range(10 ** 5 + 2)]
cnt_sum = [0] * (10 ** 5 + 2)
for _ in range(n):
    s, t, _c = map(int, input().split())
    if cnt[s + 1][_c] == -1:
        cnt[t + 1][0] -= 1
        cnt[t + 1][_c] = -1
        cnt[s + 1][0] += 1
        cnt[s + 1][_c] = 0
    elif cnt[t][_c] == 1:
        cnt[s][0] += 1
        cnt[s][_c] = 1
        cnt[t][0] -= 1
        cnt[t][_c] = 0
    else:
        cnt[s][0] += 1
        cnt[t + 1][0] -= 1
        cnt[s][_c] = 1
        cnt[t + 1][_c] = -1
cnt_sum[0] = cnt[0][0]
for i in range(1, 10 ** 5 + 2):
    cnt_sum[i] = cnt_sum[i - 1] + cnt[i][0]
print(max(cnt_sum))