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:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,c = m()

time = [[0 for i in range(31)] for j in range(10**5+2)]

for i in range(n):
    s,t,c = m()
    if time[s-1][c] == 0:
        time[t][c] = 1
        time[s-1][0] += 1    
        time[t+1][0] -= 1

    else:
        time[t][c] = 1
        time[s][0] += 1
        time[t+1][0] -= 1

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,c = m()

time = [[0 for i in range(31)] for j in range(10**5+1)]

for i in range(n):
    s,t,c = m()
    if time[s-1][c] == 0:
        time[t][c] = 1
        time[s-1][0] += 1    
        time[t][0] -= 1

    else:
        time[t][c] = 1
        time[s][0] += 1
        time[t][0] -= 1

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,c = m()

time = [[0 for i in range(31)] for j in range(10**5+1)]

for i in range(n):
    s,t,c = m()
    if time[s-1][c] == 0:
        time[t][c] = 1
        time[s-1][0] += 1    
        time[t][0] -= 1

    else:
        time[t][c] = 1
        time[s][0] += 1
        time[t][0] -= 1

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,c = m()

time = [[0 for i in range(31)] for j in range(10**5+1)]

for i in range(n):
    s,t,c = m()
    if time[s-1][c] == 0:
        time[t-1][c] = 1
        if s == 1:
            time[s-1][0] += 1
        else:
            time[s-2][0] += 1
        time[t-1][0] -= 1

    else:
        time[t-1][c] = 1
        time[s-1][0] += 1
        time[t-1][0] -= 1

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

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]
T = max(stc, key=lambda x:x[1])[1]
record = [[0]*(T+3) for _ in range(c+1)]
for s, t, c in stc:
    record[c][s] += 1
    record[c][t] -= 1

for r in record:
    for i in range(T+2):
        r[i+1] += r[i]

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

ans = 0
for i in range(T+2):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
record = [[0]*(10**5+2) for _ in range(c+1)]
stc = [list(map(int, input().split())) for _ in range(n)]

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

for r in record:
    for i in range(10**5+1):
        r[i+1] += r[i]

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

ans = 0
for i in range(10**5):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
record = [[0]*(10**5+2) for _ in range(c+1)]
stc = [list(map(int, input().split())) for _ in range(n)]

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

for r in record:
    for i in range(10**5+1):
        r[i+1] += r[i]

ans = 0
for i in range(10**5):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

T_MAX = 2*(10**5)+1

time = [[0]*(T_MAX) for _ in range(C)]
for l in L:
    for i in range(l[0]*2-1, l[1]*2+1):
        time[l[2]-1][i] += 1

ans = 0
for i in range(T_MAX):
    tmp = 0
    for j in range(C):
        tmp += time[j][i]
    ans = max(tmp, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

T_MAX = 2*(10**5)+1

time = [0]*(T_MAX)
for l in L:
    for i in range(l[0]*2-1, l[1]*2+1):
        time[i] += 1

print(max(time))

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

T_MAX = 2*(10**5)+2

time = [0]*(T_MAX)
for l in L:
    time[l[0]*2-1] += 1
    time[l[1]*2+1] -= 1

ans = 0
tmp = 0
for t in time:
    tmp += t
    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

time = [0]*(2*(10**5)+1)
for l in L:
    time[l[0]*2-1] += 1
    time[l[1]*2] -= 1

ans = 0
tmp = 0
for t in time:
    tmp += t
    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
n, channel = map(int, input().split())
STC = []
for _ in range(n):
    s, t, c = map(int, input().split())
    STC.append([2*s,2*t,c])

STC = sorted(STC, key=lambda x: (x[2], x[1]))
# print(STC)

now_s = STC[0][0]
now_t = STC[0][1]
now_c = STC[0][2]

All_bangumi = []

for i in range(1,n):
    if now_c == STC[i][2]:
        if now_t == STC[i][0]:
            now_t = STC[i][1]
            if i == n-1:
                All_bangumi.append([now_s, now_t])
        else:
            All_bangumi.append([now_s, now_t])
            now_s = STC[i][0]
            now_t = STC[i][1]

    else:   
        All_bangumi.append([now_s, now_t])
        now_s = STC[i][0]
        now_t = STC[i][1]
        now_c = STC[i][2]
        if i == n-1:
            All_bangumi.append([now_s, now_t])

for i in range(len(All_bangumi)):
    All_bangumi[i][0] = All_bangumi[i][0] -1


Imos = [0 for _ in range(2*(10**5)+1)]
for i in range(len(All_bangumi)):
    Imos[All_bangumi[i][0]] += 1
    Imos[All_bangumi[i][1]] -= 1

Imos_rui = [0]
for i in range(len(Imos)):
    Imos_rui.append(Imos_rui[-1]+Imos[i])

print(max(Imos_rui))

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heappush

N, C, *STC = map(int, open(0).read().split())

A = [[] for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
    A[c].append((2 * s - 1, 2 * t - 1))

ST = []
for a in A:
    if not a:
        continue
    a = sorted(a)
    B = [a[0]]
    for s2, t2 in a[1:]:
        s1, t1 = B[-1]
        if t1 == s2:
            B[-1] = (s1, t2)
    ST += B

ST.sort(key=lambda x: x[0])

ans = 0
Q = []
for s, t in ST:
    while Q and Q[0] < s:
        heappop(Q)
    heappush(Q, t)
    ans = max(ans, len(Q))

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heappush

N, C, *STC = map(int, open(0).read().split())

A = [[] for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
    A[c].append((s, t))

ST = []
for a in A:
    if not a:
        continue
    a = sorted(a)
    B = [a[0]]
    for s2, t2 in a[1:]:
        s1, t1 = B[-1]
        if t1 == s2:
            B[-1] = (s1, t2)
    ST += B

ST.sort(key=lambda x: x[0])

ans = 0
Q = []
for s, t in ST:
    while Q and Q[0] < s:
        heappop(Q)
    heappush(Q, t)
    ans = max(ans, len(Q))

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heappush

N, C, *STC = map(int, open(0).read().split())

A = [[] for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
    A[c].append((s, t))

ST = []
for a in A:
    if not a:
        continue
    a.sort()
    B = [a[0]]
    for s2, t2 in a[1:]:
        s1, t1 = B[-1]
        if t1 == s2:
            B[-1] = (s1, t2)
    ST += B

ST.sort(key=lambda x: x[0])

ans = 0
Q = []
for s, t in ST:
    while Q and Q[0] < s:
        heappop(Q)
    heappush(Q, t)
    ans = max(ans, len(Q))

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop

N, C, *STC = map(int, open(0).read().split())

ST = [(s, t) for s, t, _ in zip(*[iter(STC)] * 3)]

ST.sort(key=lambda x: x[0])

ans = 0
Q = []
for s, t in ST:
    while Q and Q[0] < s:
        heappop(Q)
    heappush(Q, t)
    ans = max(ans, len(Q))

print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
cnow = 0
tnow = 0
end = max(i[1] for i in stc)
imos = [0 for i in range(end+2)]
for s,t,c in stc:
    if cnow == c and tnow == s:
        imos[s]+=1
    else:
        imos[s-1] += 1
    imos[t] -=1
    cnow = c
    tnow = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
cnow = [0 for i in range(C)]
end = max(i[1] for i in stc)
imos = [0 for i in range(end+2)]
for s,t,c in stc:
    if cnow[c-1] == s:
        imos[s]+=1
    else:
        imos[s-1] += 1
    imos[t] -=1
    cnow[c-1] = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
cnow = [0 for i in range(C)]
end = max(i[1] for i in stc)
imos = [0 for i in range(end+2)]
for s,t,c in stc:
    if cnow[c-1] == s:
        imos[s+1]+=1
    else:
        imos[s] += 1
    imos[t+1] -=1
    cnow[c-1] = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
cnow = [0 for i in range(C)]
end = max(i[1] for i in stc)
imos = [0 for i in range(end+2)]
for s,t,c in stc:
    if cnow[c-1] == s-1:
        imos[s+1]+=1
    else:
        imos[s] += 1
    imos[t+1] -=1
    cnow[c-1] = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
cnow = [0 for i in range(C)]
end = max(i[1] for i in stc)
imos = [0 for i in range(end+1)]
for s,t,c in stc:
    if cnow[c-1] == s-1:
        imos[s]+=1
    else:
        imos[s-1] += 1
    imos[t] -=1
    cnow[c-1] = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
cnow = [0 for i in range(C)]
end = max(i[1] for i in stc)
imos = [0 for i in range(end+1)]
for s,t,c in stc:
    if cnow[c-1] == s:
        imos[s]+=1
    else:
        imos[s-1] += 1
    imos[t] -=1
    cnow[c-1] = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
stc = [list(map(int,input().split())) for i in range(N)]
end = max(i[1] for i in stc)
imos = [0 for i in range(end+1)]
for s,t,c in stc:
    imos[s-1] += 1
    imos[t] -=1
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
#14:29
n,c = map(int,input().split())
event = []
for _ in range(n):
  s,t,c = map(int,input().split())
  event.append([s-1,1])
  event.append([t  ,0])
event.sort()
can = []
now = 0
for x in event:
  u,i = x
  if i == 1:
    now += 1
    can.append(now)
  else:
    now -= 1
print(max(can))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]

# 同チャンネルの連続する放送を一つにまとめる
stc.sort(key=lambda x: (x[2], x[0]))
  
imos = [0] * (10**5 + 1)

curr_c = 0
for s, t, c in stc:
  if curr_c == c:
    imos[s] += 1
  else:
    imos[s-1] += 1
  imos[t] -= 1
  curr_c = c
  
rui = [0] * (10**5 + 1)

for i in range(10**5):
  rui[i+1] = rui[i] + imos[i]
  
print(max(rui))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]

imos = [0] * (10**5 + 1)

for s, t, _ in stc:
  imos[s-1] += 1
  imos[t] -= 1
  
rui = [0] * (10**5 + 1)

for i in range(10**5):
  rui[i+1] = rui[i] + imos[i]
  
print(max(rui))

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    a=[0]*(C+1)
    stc.sort(key=lambda x:x[2])
    c=1
    for i in range(N):
        while stc[i][2]!=c:
            c+=1
        if stc[i][2]==c:
            a[c]+=1
    for i in range(1,C+1):
        a[i]+=a[i-1]
    
    table=[0]*(2*10**5+5)
    for i in range(C):
        for j in range(a[i],a[i+1]):
            if j==a[i]:
                table[stc[j][0]*2-1]+=1
                table[stc[j][1]*2]-=1
            else:
                if stc[j-1][1]==stc[j][0]:
                    table[stc[j][0]*2]+=1
                    table[stc[j][1]*2]-=1
                else:
                    table[stc[j][0]*2-1]+=1
                    table[stc[j][1]*2]-=1                    
    M=1
    for i in range(len(table)):
        if 0<i:
            table[i]+=table[i-1]
    for i in range(len(table)):
        if M<table[i]:
            M=table[i]
    print(M)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    a=[0]*(C+1)
    stc.sort(key=lambda x:x[2])
    c=1
    for i in range(N):
        while stc[i][2]!=c:
            c+=1
        if stc[i][2]==c:
            a[c]+=1
    for i in range(1,C+1):
        a[i]+=a[i-1]
    
    table=[0]*(2*10**5+5)
    for i in range(C):
        for j in range(a[i],a[i+1]):
            if j==a[i]:
                table[stc[j][0]*2-1]+=1
                table[stc[j][1]*2]-=1
            else:
                if stc[j-1][1]==stc[j][0]:
                    table[stc[j][0]*2]+=1
                    table[stc[j][1]*2]-=1
                else:
                    table[stc[j][0]*2-1]+=1
                    table[stc[j][1]*2]-=1                    
    M=0
    for i in range(len(table)):
        if 0<i:
            table[i]+=table[i-1]
    for i in range(len(table)):
        if M<table[i]:
            M=table[i]
    print(M)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    a=[0]*(C+1)
    stc.sort(key=lambda x:x[2])
    c=1
    for i in range(N):
        while stc[i][2]!=c:
            c+=1
        if stc[i][2]==c:
            a[c]+=1
    for i in range(1,C+1):
        a[i]+=a[i-1]
    
    table=[0]*(2*10**5+5)
    print(len(table))
    for i in range(C):
        for j in range(a[i],a[i+1]):
            if j==a[i]:
                table[stc[j][0]*2-1]+=1
                table[stc[j][1]*2]-=1
            else:
                if stc[j-1][1]==stc[j][0]:
                    table[stc[j][0]*2]+=1
                    table[stc[j][1]*2]-=1
                else:
                    table[stc[j][0]*2-1]+=1
                    table[stc[j][1]*2]-=1                    
    M=0
    for i in range(len(table)):
        if 0<i:
            table[i]+=table[i-1]
    for i in range(len(table)):
        if M<table[i]:
            M=table[i]
    print(table[:10])
    print(M)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    a=[0]*(C+1)
    stc.sort(key=lambda x:x[2])
    c=1
    for i in range(N):
        while stc[i][2]!=c:
            c+=1
        if stc[i][2]==c:
            a[c]+=1
    for i in range(1,C+1):
        a[i]+=a[i-1]
    
    table=[0]*(2*10**5+2)
    for i in range(C):
        for j in range(a[i],a[i+1]):
            if j==a[i]:
                table[stc[j][0]*2-1]+=1
                table[stc[j][1]*2]-=1
            else:
                if stc[j-1][1]==stc[j][0]:
                    table[stc[j][0]*2]+=1
                    table[stc[j][1]*2]-=1
                else:
                    table[stc[j][0]*2-1]+=1
                    table[stc[j][1]*2]-=1                    
    M=0
    for i in range(len(table)):
        if 0<i:
            table[i]+=table[i-1]
    for i in range(len(table)):
        if M<table[i]:
            M=table[i]
    print(M)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    a=[0]*(C+1)
    stc.sort(key=lambda x:x[2])
    c=1
    for i in range(N):
        while stc[i][2]!=c:
            c+=1
        if stc[i][2]==c:
            a[c]+=1
    for i in range(1,C+1):
        a[i]+=a[i-1]
    
    table=[0]*(2*10**5+1)
    for i in range(C):
        for j in range(a[i],a[i+1]):
            if j==a[i]:
                table[stc[j][0]*2-1]+=1
                table[stc[j][1]*2]-=1
            else:
                if stc[j-1][1]==stc[j][0]:
                    table[stc[j][0]*2]+=1
                    table[stc[j][1]*2]-=1
                else:
                    table[stc[j][0]*2-1]+=1
                    table[stc[j][1]*2]-=1                    
    M=0
    for i in range(len(table)):
        if 0<i:
            table[i]+=table[i-1]
    for i in range(len(table)):
        if M<table[i]:
            M=table[i]
    print(M)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N, C = map(int, input().split())
STC = [tuple(map(int, input().split())) for _ in range(N)]
STC.sort(reverse=True, key=lambda x: x[1])  # tを基準に降順ソート

record = []
ans = 0
while STC:
    s_now, t_now, c_now = STC.pop()

    for i in range(len(record)):
        t, s, c = record[i]
        if c == c_now:
            record[i] = (t_now, s_now, c_now)
            break
        elif s_now > t:
            record[i] = (t_now, s_now, c_now)
            break
    else:
        record.append((t_now, s_now, c_now))


print(len(record))

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    stc.sort()
    flag=False
    max_count=0
    chain=[]
    for i in range(N):
        if i==0:
            count=1
            max_count=max(count,max_count)
        else:
            if stc[i-1][1]>stc[i][0]-0.5 and flag==False:
                if stc[i-1][2]!=stc[i][2]:
                    count=2
                    max_count=max(count,max_count)
                    flag=True
                    chain=[i-1,i]
            elif flag:
                for j in chain:
                    if stc[j][1]<=stc[i][0]-0.5:
                        flag=False
                if flag:
                    for j in chain:
                        if stc[j][2]==stc[i][2]:
                            flag=False
                if flag:
                    count+=1
                    max_count=max(count,max_count)
                    chain.append(i)
    print(max_count)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    stc.sort()
    flag=False
    max_count=0
    chain=[]
    for i in range(N):
        if i==0:
            count=1
            max_count=max(count,max_count)
        else:
            if stc[i-1][1]>stc[i][0]-0.5 and flag==False:
                if stc[i-1][2]!=stc[i][2]:
                    count=2
                    max_count=max(count,max_count)
                    flag=True
                    chain=[i-1,i]
            elif flag:
                for j in chain:
                    if stc[j][1]<=stc[i][1]-0.5:
                        flag=False
                        chain=[]
                if flag:
                    for j in chain:
                        if stc[j][2]==stc[i][2]:
                            flag=False
                            chain=[]
                if flag:
                    count+=1
                    max_count=max(count,max_count)
                    chain.append(i)
    print(max_count)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    stc.sort()
    print(stc)
    flag=False
    max_count=0
    chain=[]
    for i in range(N):
        if i==0:
            count=1
            max_count=max(count,max_count)
        else:
            if stc[i-1][1]>stc[i][0]-0.5 and flag==False:
                if stc[i-1][2]!=stc[i][2]:
                    count=2
                    max_count=max(count,max_count)
                    flag=True
                    chain=[i-1,i]
            elif flag:
                for j in chain:
                    if stc[j][1]<=stc[i][1]-0.5:
                        flag=False
                        chain=[]
                if flag:
                    for j in chain:
                        if stc[j][2]==stc[i][2]:
                            flag=False
                            chain=[]
                if flag:
                    count+=1
                    max_count=max(count,max_count)
                    chain.append(i)
    print(max_count)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,C=map(int,input().split())
    stc=[0]*N
    for i in range(N):
        abc=list(map(int,input().split()))
        stc[i]=abc

    stc.sort()
    print(stc)
    flag=False
    max_count=0
    chain=[]
    for i in range(N):
        if i==0:
            count=1
            max_count=max(count,max_count)
        else:
            if stc[i-1][1]>stc[i][0]-0.5 and flag==False:
                if stc[i-1][2]!=stc[i][2]:
                    count=2
                    max_count=max(count,max_count)
                    flag=True
                    chain=[i-1,i]
            elif flag:
                for j in chain:
                    if stc[j][1]<=stc[i][1]-0.5:
                        flag=False
                        chain=[]
                if flag:
                    for j in chain:
                        if stc[j][2]==stc[i][2]:
                            flag=False
                            chain=[]
                if flag:
                    count+=1
                    max_count=max(count,max_count)
                    chain.append(i)
    print(max_count)

    print(count)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
STC = [tuple(map(int,input().split())) for i in range(N)]

cs = [[] for _ in range(30)]
for s,t,c in STC:
    cs[c-1].append((s,t))

imos = [0]*(100005)
for c in cs:
    pt = -1
    for s,t in c:
        if s==pt:
            imos[s] += 1
        else:
            imos[s-1] += 1
        imos[t] -= 1
        pt = t
for i in range(len(imos)-1):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
STC = [tuple(map(int,input().split())) for i in range(N)]

cs = [[] for _ in range(30)]
for s,t,c in STC:
    cs[c-1].append((s,t))

imos = [0]*(200005)
for c in cs:
    pt = -1
    for s,t in c:
        if s==pt:
            imos[2*s] += 1
        else:
            imos[2*s-1] += 1
        imos[2*t] -= 1
        pt = t
for i in range(len(imos)-1):
    imos[i+1] += imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N, C = map(int, input().split())
STC = [tuple(map(int, input().split())) for _ in range(N)]
STC.sort(reverse=True, key=lambda x: x[1])  # tを基準に降順ソート

record = []
ans = 0
while STC:
    s_now, t_now, c_now = STC.pop()

    for i in range(len(record)):
        t, s, c = record[i]
        if c == c_now:
            record[i] = (t_now, s_now, c_now)
            break
        elif s_now > t:
            record[i] = (t_now, s_now, c_now)
            break
    else:
        record.append((t_now, s_now, c_now))

    ans = max(ans, len(record))

print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
STC = [tuple(map(int,input().split())) for i in range(N)]

imos = [0]*(200005)
for s,t,_ in STC:
    imos[2*s-1] += 1
    imos[2*t] -= 1

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

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
time=[0]*(10**5*2+2)
stc=[]
for i in range(n):
	s,t,c=map(int,input().split())
	stc.append([s,t,c])
stc.sort(key=lambda x:x[2])
for i in range(n-1):
	if stc[i][2]==stc[i+1][2]:
		if stc[i][1]==stc[i+1][0]:
			stc[i+1][0]=stc[i][0]
			stc[i]=[-1]
lis=[]
for i in range(n):
	if stc[i]!=[-1]:
		lis.append(stc[i])
for i in range(len(lis)):
	time[lis[i][0]*2-1]+=1
	time[lis[i][1]*2]-=1
for i in range(10**5*2+1):
	time[i+1]+=time[i]
print(max(time))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
time=[0]*(10**5*2+2)
stc=[]
for i in range(n):
	s,t,c=map(int,input().split())
	stc.append([s,t,c])
stc.sort(key=lambda x:x[2])
for i in range(n-1):
	if stc[i][2]==stc[i+1][2]:
		if stc[i][1]==stc[i+1][0]:
			stc[i+1][0]=stc[i][0]
			stc[i]=[-1]
lis=[]
for i in range(n):
	if stc[i]!=[-1]:
		lis.append(stc[i])
for i in range(len(lis)):
	time[lis[i][0]*2-1]+=1
	time[lis[i][1]*2+1]-=1
for i in range(10**5*2+1):
	time[i+1]+=time[i]
print(max(time))