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:
from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
s=[0]*(2*10**5+2)
for i in b:
    for h,w in i:
        s[2*h-1]+=1
        s[2*w+1]-=1
print(max(list(ac(s))))

Submission status: Wrong Answer

Solution code:
from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
s=[0]*(10**5+2)
for i in b:
    for h,w in i:
        s[h-1]+=1
        s[w+1]-=1
print(max(list(ac(s))))

Submission status: Wrong Answer

Solution code:
from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
s=[0]*(10**5+2)
for i in b:
    for h,w in i:
        s[h-1]+=1
        s[w]-=1
print(max(list(ac(s))))

Submission status: Wrong Answer

Solution code:
from heapq import *
from itertools import accumulate as ac
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
s=[0]*(10**5+2)
for i in b:
    for h,w in i:
        s[h]+=1
        s[w]-=1
print(sum(list(ac(s))))

Submission status: Wrong Answer

Solution code:
from heapq import *
from itertools import chain
n,c=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)])
b=[[]for i in range(c+1)]
for i,j,h in a:
    if len(b[h])>0:
        if b[h][-1][1]==i:
            b[h][-1][1]=j
    else:
        b[h].append([i,j])
d=sorted(chain.from_iterable(b))
b=[d[0][1]]
for i,j in d[1:]:
    s=heappop(b)
    if i<=s:
        heappush(b,s)
        heappush(b,j)
    else:
        heappush(b,j)
print(len(b))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
l=sorted([list(map(int,input().split())) for _ in [0]*n],key=lambda x:[x[2],x[0]])
m=[l[0]]
for i in range(1,n):
    if l[i][2]==m[-1][2] and l[i][0]-m[-1][1]<=2:
        m.append([m.pop()[0],l[i][1],l[i][2]])
    else:m.append(l[i])
for x in m:
    x[0]-=1
ans=[0]*max(x[1] for x in m)
for x in m:
    for i in range(x[0],x[1]):
        ans[i]+=1
print(max(ans))

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heappush, heapify

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

heapify(stc)
end = []
ans = 0
while len(stc) > 0:
    s, t, c = heappop(stc)
    if len(end) > 0:
        endtime = heappop(end)
        if endtime > s:
            heappush(end, endtime)
    heappush(end, t)
    ans = max(ans, len(end))
print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heappush, heapify

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

heapify(stc)
end = []
ans = 0
while len(stc) > 0:
    s, t, c = heappop(stc)
    if len(end) > 0:
        endtime = heappop(end)
        if endtime >= s:
            heappush(end, endtime)
    heappush(end, t)
    ans = max(ans, len(end))
print(ans)

Submission status: Wrong Answer

Solution code:
"""
https://atcoder.jp/contests/abc080/tasks/abc080_d
400

同じチャンネル同士でかぶりが発生するとアウト
imos
"""

N,C  = map(int, input().split())
t_max = 2*10**5+1
c_imos = [[0]*t_max for t in range(C)]
# 前処理 : 同一チャンネルのときはくっつけられる
programs = []
for i in range(N):
    s,t,c = map(int, input().split())
    programs.append((c,s,t))
programs.sort()

imos = [0] * t_max
prev_c =  -1

for c, s, t  in programs:
    c -= 1
    s *= 2
    t *= 2
    # チャンネルが変わったらラグが発生する
    if prev_c != c:
        s -= 1
        
    imos[s] += 1
    imos[t] -= 1 
    prev_c = c
    
from itertools import accumulate    
print(max(list(accumulate(imos))))

Submission status: Wrong Answer

Solution code:


N,C  = map(int, input().split())
t_max = 2*10**5
c_imos = [[0]*t_max for t in range(C)]
# 前処理 : 同一チャンネルのときはくっつけられる
programs = []
for i in range(N):
    s,t,c = map(int, input().split())
    programs.append((c,s,t))
programs.sort()

imos = [0] * t_max
prev_c =  -1
for c, s, t  in programs:
    c -= 1

    # チャンネルが変わったらラグが発生する
    if prev_c != c:
        s -= 1
        
    imos[s] += 1
    imos[t] -= 1 
    prev_c = c
    
from itertools import accumulate    
print(max(list(accumulate(imos))))

Submission status: Wrong Answer

Solution code:
"""
https://atcoder.jp/contests/abc080/tasks/abc080_d
400

同じチャンネル同士でかぶりが発生するとアウト
imos
"""

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

    # for c_ in c_imos:
    #     print(list(accumulate(c_)))
    
from itertools import accumulate
print(max(list(accumulate(imos))))

Submission status: Wrong Answer

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

nums = []
for i in range(C):
    if len(stc[i]) == 0:
        continue
    stc[i].sort()
    res1 = stc[i][0][0]
    res2 = 0
    for j in range(len(stc[i])):
        res2 = max(res2, stc[i][j][1])
    nums.append([res1, res2])

imos = [0] * 100010

for i, j in nums:
    imos[i] = 1
    imos[j+1] = -1

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

cnt = -1
for i in range(len(imos)-1):
    if imos[i] == 0 and imos[i+1]:
        cnt += 1

print(len(nums)-cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]
# lst = [[0] * (20) for _ in range(C + 1)]

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

# # 累積和の計算
# import numpy as np
# A = np.array(lst)
# print (A)
# np.cumsum(A, axis = 1, out = A)
# print (A)
# np.cumsum(A, axis = 0)

# print (np.max(A[-1:]))
# print (A)

for i in range(1, C + 1):
    for j in range(1, 10 ** 5 + 10):
    # for j in range(1, 20):
        lst[i][j] += lst[i][j - 1]
    for j in range(1, 20):
        lst[i][j] = min(1, lst[i][j])

# for i in lst:
#     print (i[:20])

for j in range(1, 10 ** 5 + 10):
# for j in range(1, 20):
    for i in range(1, C + 1):
        lst[i][j] += lst[i - 1][j]

print (max(lst[-1]))
    
# for i in lst:
#     print (i[:20])

Submission status: Wrong Answer

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

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]
# lst = [[0] * (20) for _ in range(C + 1)]

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

# # 累積和の計算
# import numpy as np
# A = np.array(lst)
# print (A)
# np.cumsum(A, axis = 1, out = A)
# print (A)
# np.cumsum(A, axis = 0)

# print (np.max(A[-1:]))
# print (A)

for i in range(1, C + 1):
    for j in range(1, 10 ** 5 + 10):
    # for j in range(1, 20):
        lst[i][j] += lst[i][j - 1]
    for j in range(1, 20):
        lst[i][j] = min(1, lst[i][j])

# for i in lst:
#     print (i[:20])

for j in range(1, 10 ** 5 + 10):
# for j in range(1, 20):
    for i in range(1, C + 1):
        lst[i][j] += lst[i - 1][j]

print (max(lst[-1]) - 1)
    
# for i in lst:
#     print (i[:20])

Submission status: Wrong Answer

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

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]
# lst = [[0] * (20) for _ in range(C + 1)]

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

# # 累積和の計算
# import numpy as np
# A = np.array(lst)
# print (A)
# np.cumsum(A, axis = 1, out = A)
# print (A)
# np.cumsum(A, axis = 0)

# print (np.max(A[-1:]))
# print (A)

for i in range(1, C + 1):
    for j in range(1, 10 ** 5 + 10):
    # for j in range(1, 20):
        lst[i][j] += lst[i][j - 1]
    for j in range(1, 20):
        lst[i][j] = min(1, lst[i][j])

# for i in lst:
#     print (i[:20])

for j in range(1, 10 ** 5 + 10):
# for j in range(1, 20):
    for i in range(1, C + 1):
        lst[i][j] += lst[i - 1][j]

print (max(lst[-1]) + 1)
    
# for i in lst:
#     print (i[:20])

Submission status: Wrong Answer

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

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]
# lst = [[0] * (20) for _ in range(C + 1)]

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

# # 累積和の計算
# import numpy as np
# A = np.array(lst)
# print (A)
# np.cumsum(A, axis = 1, out = A)
# print (A)
# np.cumsum(A, axis = 0)

# print (np.max(A[-1:]))
# print (A)

for i in range(1, C + 1):
    for j in range(1, 10 ** 5 + 10):
    # for j in range(1, 20):
        lst[i][j] += lst[i][j - 1]
    for j in range(1, 20):
        lst[i][j] = min(1, lst[i][j])

# for i in lst:
#     print (i[:20])

for j in range(1, 10 ** 5 + 10):
# for j in range(1, 20):
    for i in range(1, C + 1):
        lst[i][j] += lst[i - 1][j]

print (max(lst[-1]))
    
# for i in lst:
#     print (i[:20])

Submission status: Wrong Answer

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

# 入力
lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]
# lst = [[0] * (20) for _ in range(C + 1)]

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

# # 累積和の計算
# import numpy as np
# A = np.array(lst)
# print (A)
# np.cumsum(A, axis = 1, out = A)
# print (A)
# np.cumsum(A, axis = 0)

# print (np.max(A[-1:]))
# print (A)

for i in range(1, C + 1):
    for j in range(1, 10 ** 5 + 10):
        lst[i][j] += lst[i][j - 1]
    for j in range(1, 20):
        lst[i][j] = min(1, lst[i][j])

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

print (max(lst[-1]))

Submission status: Wrong Answer

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


lst = [0] * (10 ** 5 + 10)
for _ in range(N):
    s, t, c = map(int, input().split())
    lst[s] += 1
    lst[t + 1] -= 1

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

# print (lst)
print (max(lst))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
ps = [[] for _ in range(C)]
for _ in range(N):
    s,t,c = map(int, input().split())
    ps[c-1].append((s,t))

imos = [0]*(10**5+3)
for c in range(C):
    ps[c].sort()
    cont = False
    for i, (s, t) in enumerate(ps[c]):
        imos[s-1] += 1
        imos[t] -= 1

ans = t = 0
for a in imos:
    t += a
    ans = max(ans, t)
print(ans)

Submission status: Wrong Answer

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

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

rec = [0] * (10 ** 5 + 1)
cs = [[]] * (10 ** 5 + 1)

for s, t, c in TV:
    rec[t] -= 1
    if c not in cs[s]:
        rec[s - 1] += 1
    else:
        rec[s] += 1
    cs[t].append(c)

rec_s = [rec[0]]
for r in rec[1:]:
    rec_s.append(rec_s[-1] + r)

print(max(rec_s))

Submission status: Wrong Answer

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

TV.sort()

rec = [0] * (10 ** 5 + 1)
cs = [[]] * (10 ** 5 + 1)

for s, t, c in TV:
    rec[t] -= 1
    if c not in cs[s]:
        rec[s - 1] += 1
    else:
        rec[s] += 1
    cs[t].append(c)

rec_s = [rec[0]]
for r in rec[1:]:
    rec_s.append(rec_s[-1] + r)

print(max(rec_s))

Submission status: Wrong Answer

Solution code:
n,c = map(int,input().split())
arr = [0 for i in range(10**5+1)]
tv = [[0,0,0] for i in range(n)]
for i in range(n):
    s,t,c = map(int,input().split())
    tv[i][0] = s
    tv[i][1] = t
    tv[i][2] = c

tv.sort(key = lambda x:(x[2],x[0]))
# print(tv)

channel = tv[0][2]
for i in range(n):
    bef = -1
    if channel != tv[i][2]:
        channel = tv[i][2]
        bef = -1
        s = tv[i][0]
        e = tv[i][1]
        if bef != s:
            arr[s]+=1
        bef = e
        for j in range(s+1,e+1):
            arr[j] += 1
    else:
        s = tv[i][0]
        e = tv[i][1]
        if bef != s:
            arr[s]+=1
        bef = e
        for j in range(s+1,e+1):
            arr[j] += 1
# print(arr[:13])
print(max(arr))

Submission status: Wrong Answer

Solution code:
n,c = map(int,input().split())
arr = [0 for i in range(10**5+1)]
tv = [[0,0,0] for i in range(n)]
for i in range(n):
    s,t,c = map(int,input().split())
    tv[i][0] = s
    tv[i][1] = t
    tv[i][2] = c

tv.sort(key = lambda x:x[2])
# print(tv)

channel = tv[0][2]
for i in range(n):
    bef = -1
    if channel != tv[i][2]:
        channel = tv[i][2]
        bef = -1
        s = tv[i][0]
        e = tv[i][1]
        if bef != s:
            arr[s]+=1
        bef = e
        for j in range(s+1,e+1):
            arr[j] += 1
    else:
        s = tv[i][0]
        e = tv[i][1]
        if bef != s:
            arr[s]+=1
        bef = e
        for j in range(s+1,e+1):
            arr[j] += 1
# print(arr[:13])
print(max(arr))

Submission status: Wrong Answer

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

TV = sorted([[l[0] - 0.5, l[1], l[2]] for l in TV], key=lambda x: x[1])

c = 0
while TV:
    c += 1
    end = 0
    l_rem = []
    for i, tv in enumerate(TV):
        if tv[0] >= end:
            end = tv[1]
            l_rem.append(i)
    for i in reversed(l_rem):
        TV.pop(i)

print(c)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

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

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s * 2 - 1] += 1
        imos[t * 2] -= 1
    for i in range(1, 20200) :
        imos[i] += imos[i - 1]
    for i in range(20200) :
        if imos[i] > 0 :
            tvSum[i] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

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

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1
    for i in range(1, 20200) :
        imos[i] += imos[i - 1]
    for i in range(20200) :
        if imos[i] > 0 :
            tvSum[i] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

for _ in range(N) :
    s, t, c = map(int, input().split())
    channels[c - 1].append((s * 2 - 1, t * 2))

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1
    for i in range(1, 20200) :
        imos[i] += imos[i - 1]
    for i in range(20200) :
        if imos[i] > 0 :
            tvSum[i] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

for _ in range(N) :
    s, t, c = map(int, input().split())
    channels[c - 1].append((s * 2 - 1, t * 2))

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1
    for i in range(1, 20200 - 1) :
        imos[i] += imos[i - 1]
    for i in range(20200) :
        if imos[i] > 0 :
            tvSum[i] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

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

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1
    for i in range(1, 20200 - 1) :
        imos[i] += imos[i - 1]
    for i in range(20200) :
        if imos[i] > 0 :
            tvSum[i] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

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

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1
    for i in range(1, 20200 - 1) :
        imos[i] += imos[i - 1]
        if imos[i - 1] > 0 :
            tvSum[i - 1] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

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

tvSum = [0] * 202000

for c in range(C) :
    imos = [0] * 202000
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1
    for i in range(1, 20200 - 1) :
        imos[i] += imos[i - 1]
        if imos[i] > 0 :
            tvSum[i] += 1

ans = 0

for i in range(20200) :
    ans = max(ans, tvSum[i])

print(ans)

Submission status: Wrong Answer

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

channels = [[] for _ in range(C)]

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

imos = [0] * 202000
for c in range(C) :
    for (s, t) in channels[c] :
        imos[s] += 1
        imos[t] -= 1

ans = 0
now = 0
for i in range(20200) :
    now += imos[i]
    ans = max(ans, now)

print(ans)

Submission status: Wrong Answer

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

channels = [0] * N

for i in range(N) :
    s, t, c = map(int, input().split())
    channels[i] = (s * 2, t * 2 + 1)  # 0.5 を整数に変換し，シフト

imos = [0] * 202000

for (s, t) in channels :
    imos[s] += 1
    imos[t] -= 1

ans = 0
now = 0

for i in range(20200) :
    now += imos[i]
    ans = max(ans, now)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,C = inputMap()
    D = [0 for i in range((10**5)+1)]
    
    for i in range(N):
        s, t, c = inputMap()
        D[s-1] += 1
        D[t] -= 1
        
    ans = 0
    for i in range(1, (10*5)+1):
        D[i] = D[i] + D[i-1]
        
        if ans < D[i]:
            ans = D[i]
        
    print(ans)
            	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# dp[i][j]
def init_dp_table(i, j, init=INF):
  return [[ init for _ in range(j)] for _ in range(i)]

########

N, C = l_inpl()
s, t, c = [], [], []
for _ in range(N):
  si, ti, ci = l_inpl()
  s.append(si)
  t.append(ti)
  c.append(ci)

T = max(t) * 2 +10
table = [0] * T

for c_i in range(1, C+1):
  tabel_c = [0] * T
  before_ti = -1
  for si, ti, ci in zip(s, t, c):
    if c_i == ci:
      if before_ti == 2*si:
        tabel_c[before_ti] += 1
        tabel_c[2*ti] -= 2
      else:
        tabel_c[2*si-1] += 1
        tabel_c[2*ti] -= 1
      before_ti = 2*ti
  for i in range(T):
    table[i] += tabel_c[i]

for i in range(T):
  table[i] += table[i-1]

print(max(table))

Submission status: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# dp[i][j]
def init_dp_table(i, j, init=INF):
  return [[ init for _ in range(j)] for _ in range(i)]

########

N, C = l_inpl()
d = defaultdict(list)
for _ in range(N):
  si, ti, ci = l_inpl()
  if len(d[ci]) > 0:
    if d[ci][-1][1] <= si*2:
      d[ci][-1][1] = ti*2
    else:
      d[ci].append([2*si-1, 2*ti])
  else:
    d[ci].append([2*si-1, 2*ti])

table = [0 for _ in range(200005)]
for l in d.values():
  for si, ti in l:
    table[si] += 1
    table[ti] -= 1


for i in range(200005):
  table[i] += table[i-1]

print(max(table))

Submission status: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# dp[i][j]
def init_dp_table(i, j, init=INF):
  return [[ init for _ in range(j)] for _ in range(i)]

########

N, C = l_inpl()
d = defaultdict(list)
for _ in range(N):
  si, ti, ci = l_inpl()
  if len(d[ci]) > 0:
    if d[ci][-1][1] == si*2:
      d[ci][-1][1] = ti*2
    else:
      d[ci].append([2*si-1, 2*ti])
  else:
    d[ci].append([2*si-1, 2*ti])

table = [0 for _ in range(200000+10)]
for l in d.values():
  for si, ti in l:
    table[si] += 1
    table[ti] -= 1


for i in range(200000+10):
  table[i] += table[i-1]

print(max(table))

Submission status: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# dp[i][j]
def init_dp_table(i, j, init=INF):
  return [[ init for _ in range(j)] for _ in range(i)]

########

N, C = l_inpl()
d = defaultdict(list)
for _ in range(N):
  si, ti, ci = l_inpl()
  if len(d[ci]) > 0:
    if d[ci][-1][1] == si*2:
      d[ci][-1][1] = ti*2
    else:
      d[ci].append([2*si-1, 2*ti])
  else:
    d[ci].append([2*si-1, 2*ti])

table = [0 for _ in range(200000+10)]
for l in d.values():
  for si, ti in l:
    table[si] += 1
    table[ti] -= 1


for i in range(200000+10):
  if i > 0:
    table[i] += table[i-1]

print(max(table))

Submission status: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# dp[i][j]
def init_dp_table(i, j, init=INF):
  return [[ init for _ in range(j)] for _ in range(i)]

########

N, C = l_inpl()
s, t, c = [], [], []
for _ in range(N):
  si, ti, ci = l_inpl()
  s.append(2*si-1)
  t.append(2*ti)
  c.append(ci)

max_t = max(t)

table = [0 for _ in range(max_t+1)]
for si, ti, ci in zip(s, t, c):
  table[si] += 1
  table[ti] -= 1


for i in range(max_t):
  if i > 0:
    table[i] += table[i-1]

print(max(table))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
P = [[] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    P[c - 1].append((s, t))

Q = []
for c in range(C):
    P[c].sort(key=lambda pair: pair[0])
    i = 0
    while i < len(P[c]) - 1:
        if P[c][i][1] == P[c][i + 1][0]:
            p = (P[c][i][0], P[c][i + 1][1])
            del P[c][i]
            P[c][i] = p
        else:
            i += 1
    Q.extend(P[c])
Q.sort(key=lambda pair: pair[0])

ans = 0
while Q:
    i = 0
    j = 0
    while i < len(Q) - 1:
        if Q[i][1] < Q[i + 1][0]:
            q = (Q[i][0], Q[i + 1][1])
            del Q[i]
            Q[i] = q
            j = i
        else:
            i += 1
    del Q[j]
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())

r = [0] * (10**5 + 5)
i_max = 0
for _ in range(n):
    s, t, _ = map(int, input().split())
    r[s] += 1
    r[t+1] -= 1
    i_max = max(i_max, t+1)

ans = 0
for i in range(1, i_max+1):
    r[i] = r[i-1] + r[i]
    ans = max(ans, r[i])

print(ans)

Submission status: Wrong Answer

Solution code:
n,C=[int(i) for i in input().split()]
stc=[[int(i) for i in input().split()] for _ in range(n)]
stc.sort(key=lambda x:x[1])
stc.sort(key=lambda x:x[2])
time=[0]*(2*(10**5+1))
end=[[0]*(10**5+1) for _ in range(C)]

for s,t,c in stc:
    end[c-1][t]+=1

for s,t,c in stc:
    if end[c-1][s]==0:
        time[2*s-1]+=1
        time[2*t]-=1
for i in range(1,2*10**5+2):
    time[i]=time[i-1]+time[i]
print(max(time))