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())
l=[]
ansl=[[] for i in range(c)]
memo=[0 for i in range(10**5+10)]
for i in range(n):
    s,t,c=[int(x) for x in input().rstrip().split()]
    l.append([s,t,c])

for s,e,ch in l:
    memo[s]+=1
    memo[e+1]-=1

ruiseki=[memo[0]]
for i in range(1,10**5+10):
    ruiseki.append(ruiseki[i-1]+memo[i])

print(max(ruiseki))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
l=[]
ansl=[[] for i in range(c)]
memo=[0 for i in range(10**5+10)]
for i in range(n):
    s,t,c=[int(x) for x in input().rstrip().split()]
    l.append([s,t,c])

for s,e,ch in l:
    memo[s]+=1
    memo[e+1]-=1

ruiseki=[0]
for i in range(1,10**5+10):
    ruiseki.append(ruiseki[i-1]+memo[i])

# print(memo)
# print(ruiseki[:100])
# print(memo[:100])
print(max(ruiseki))

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()


def main():
    n, c = map(int, input().split())
    schedule = [0] * (10**5 + 3)
    for _ in range(n):
        s, t, c = map(int, input().split())
        schedule[s- 1] += 1
        schedule[t] -= 1
    total = accumulate(schedule)
    print(max(total))
    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    n, c = map(int, input().split())
    program = []
    for _ in range(n):
        s, t, c = map(int, input().split())
        heappush(program, (s - 1, t, c))
    
    recorder = 1
    watching = []
    for time in range(10**5 + 2):
        # レコーダー回収
        while watching and watching[0][0] == time:
            t, c = heappop(watching)
            recorder += 1
        # レコーダー割り当て
        while program and program[0][0] == time:
            s, t, c = heappop(program)
            if recorder > 0: recorder -= 1
            heappush(watching, (t, c))
    print(recorder)





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
max_size = 10 ** 5
record_list = [[int(i) - 1 for i in input().split()] for _ in range(N)]
ans_list = [0 for _ in range(max_size)]
for c in range(C):
    T = [0 for _ in range(max_size + 1)]
    for s, t, i in record_list:
        if i == c:
            T[s] += 1
            T[t + 1] -= 1
    for i in range(max_size):
        T[i + 1] += T[i]
    for i in range(max_size):
        ans_list[i] += T[i]
print(max(ans_list))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5 + 2
S = [0] * m
for x in range(1, C + 1):
    T = [0] * m
    for s, t, c in L:
        if c == x:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(1, m):
        T[i] += T[i - 1]
    for i in range(m):
        if T[i] > 0:
            S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5 + 2
S = [0] * m
for x in range(1, C + 1):
    T = [0] * (m + 2)
    for s, t, c in L:
        if c == x:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(1, m):
        T[i] += T[i - 1]
    for i in range(m):
        if T[i] > 0:
            S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5 + 2
S = [0] * m
for x in range(1, C + 1):
    T = [0] * (m + 2)
    for s, t, c in L:
        if c == x:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        if T[i] > 0:
            S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5 + 1 
S = [0] * m
for x in range(1, C + 1):
    T = [0] * (m + 2)
    for s, t, c in L:
        if c == x:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        if T[i] > 0:
            S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5 + 1 
S = [0] * m
for i in range(1, C + 1):
    T = [0] * (m + 2)
    for s, t, c in L:
        if c == i:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        if T[i] > 0:
            S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5 + 1 
S = [0] * m
for i in range(1, C + 1):
    T = [0] * (m + 2)
    for s, t, c in L:
        if c == i:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 2 * 10 ** 5
S = [0] * m
for i in range(1, C + 1):
    T = [0] * (m + 1)
    for s, t, c in L:
        if c == i:
            # 始点を奇数, 終点を偶数にするのうまい
            T[2 * s - 1] += 1
            T[2 * t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 10 ** 5
S = [0] * m
for i in range(1, C + 1):
    T = [0] * (m + 1)
    for s, t, c in L:
        if c == i:
            if T[t - 1] == 1:
                T[t - 1] = 0
            elif T[s] == -1:
                T[s] = 0
            else:
                T[s - 1] += 1
                T[t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

Solution code:
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 10 ** 5
S = [0] * m
for i in range(1, C + 1):
    T = [0] * (m + 1)
    for s, t, c in L:
        if c == i:
            T[s - 1] += 1
            T[t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        S[i] += T[i]
print(max(S))

Submission status: Wrong Answer

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

def main():
  n, c = map(int, input().split())
  count = [0]*(10**5+10)
  sub = dict()
  for i in range(n):
    s, t, c = map(int, input().split())
    if (c, s) in sub:
      sub[(c, t)] = sub[(c, s)]
      count[s+1] += 1
      count[t+1] -= 1
    else:
      count[s] += 1
      count[t+1] -= 1
      sub[(c, t)] = s
  
  ans = 0
  for i in range(1, 10**5+10):
    count[i] += count[i-1]
    if ans < count[i]:
      ans = count[i]
  
  print(ans)
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

def main():
  n, c = map(int, input().split())
  count = [0]*(2*10**5+10)
  sub = dict()
  for i in range(n):
    s, t, c = map(int, input().split())
    if (c, s) in sub:
      sub[(c, t)] = sub[(c, s)]
      count[2*s+1] += 1
      count[2*t+1] -= 1
    else:
      count[2*s] += 1
      count[2*t+1] -= 1
      sub[(c, t)] = s
  
  ans = 0
  for i in range(1, 2*10**5+10):
    count[i] += count[i-1]
    if ans < count[i]:
      ans = count[i]
  
  print(ans)
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

def main():
  n, c = map(int, input().split())
  count = [0]*(2*10**5+10)
  
  for i in range(n):
    s, t, c = map(int, input().split())
    count[2*s] += 1
    count[2*t+1] -= 1
  
  ans = 0
  for i in range(1, 2*10**5+10):
    count[i] += count[i-1]
    if ans < count[i]:
      ans = count[i]
  
  print(ans)
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

def main():
  n, c = map(int, input().split())
  count = [0]*(10**5+10)
  
  for i in range(n):
    s, t, c = map(int, input().split())
    count[s] += 1
    count[t+1] -= 1
  
  ans = 0
  for i in range(1, 10**5+10):
    count[i] += count[i-1]
    if ans < count[i]:
      ans = count[i]
  
  print(ans)
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop
n,c=map(int,input().split())
n_max=2*10**5+1
imos=[0]*n_max
a=[]
c1=c
for _ in range(n):
  s,t,c=map(int,input().split())
  heappush(a,(c,s,t))
while a:
  c,s,t=heappop(a)
  if c1==c:
    imos[2*s]+=1
    imos[2*t]-=1
  else:
    imos[2*s-1]+=1
    imos[2*t]-=1
    c1=c
for i in range(n_max-1):
  imos[i+1]+=imos[i]
print(max(imos))

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop
n,c=map(int,input().split())
n_max=10**5+1
imos=[0]*n_max
a=[]
c1=c
for _ in range(n):
  s,t,c=map(int,input().split())
  heappush(a,(c,s,t))
while a:
  c,s,t=heappop(a)
  if c1==c:
    imos[s]+=1
    imos[t]-=1
  else:
    imos[s-1]+=1
    imos[t]-=1
    c1=c
for i in range(n_max-1):
  imos[i+1]+=imos[i]
print(max(imos))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,c=list(map(int,input().split()))
d=[0]*10**6

for _ in range(n):
    s,t,c=list(map(int,input().split()))

    d[2*s-1]+=1
    d[2*t]-=1

ans=0

for time in range(1,3*10**5):
    d[time]+=d[time-1]
    ans=max(ans,d[time])

print(ans)

Submission status: Wrong Answer

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

#同じチャンネルで連続する番組についてはダブりなく一つの録画機で録画できる
for s,t,c in stc:
    c-=1
    if time[c][s] == -1:#録画を開始する時に前の録画が終了していれば連続で録画
        time[c][s] = 0
    else:
        time[c][s-1]+=1
    if time[c][t-1] == 1:#録画が終了するときに次の番組があれば連続で録画
        time[c][t-1] = 0
    else:
        time[c-1][t]-=1

count = [0]*(10**5+1)
for i in range(C):
    for j in range(10**5+1):
        count[j] += time[i][j]
ans = count[0]
for i in range(10**5):
    count[i+1] += count[i]
    if count[i+1] > ans:
        ans = count[i+1]
print(ans)

Submission status: Wrong Answer

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

#同じチャンネルで連続する番組についてはダブりなく一つの録画機で録画できる
for s,t,c in stc:
    c-=1
    if time[c][s] == -1:#録画を開始する時に前の録画が終了していれば連続で録画
        time[c][s] = 0
    else:
        time[c][s-1]+=1
    if time[c][t-1] == 1:#録画が終了するときに次の番組があれば連続で録画
        time[c][t-1] = 0
    else:
        time[c-1][t]-=1

count = [0]*(10**5+1)
for i in range(C):
    for j in range(10**5):
        count[j] += time[i][j]
ans = count[0]
for i in range(10**5):
    count[i+1] += count[i]
    if count[i+1] > ans:
        ans = count[i+1]
print(ans)

Submission status: Wrong Answer

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

#同じチャンネルで連続する番組についてはダブりなく一つの録画機で録画できる
for s,t,c in stc:
    c-=1
    if time[c][s] == -1:#録画を開始する時に前の録画が終了していれば連続で録画
        time[c][s] = 0
    else:
        time[c][s-1]+=1
    if time[c][t-1] == 1:#録画が終了するときに次の番組があれば連続で録画
        time[c][t-1] = 0
    else:
        time[c-1][t]-=1
ans = 0
count = [0]*(10**5+1)
for i in range(C):
    for j in range(10**5):
        count[j] += time[i][j]
for i in range(10**5):
    count[i+1] += count[i]
    if count[i+1] > ans:
        ans = count[i+1]
print(ans)

Submission status: Wrong Answer

Solution code:
n,C = map(int, input().split())
stc=[list(map(int,input().split())) for _ in range(n)]
time = [0]*(10**5+1)
for s,t,c in stc:
    time[s-1]+=1
    time[t]-=1
ans = time[0]
for i in range(10**5):
    time[i+1] += time[i]
    if time[i+1] > ans:
        ans = time[i+1]
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc080/tasks/abc080_d
# D - Recording

N,C = map(int,input().split())
s=[0]*N
t=[0]*N
c=[0]*N
f=[False]*C
L=[]
for i in range(N):
    s[i],t[i],c[i]= map(int,input().split())
    L.append( [s[i]-0.5,c[i]-1,1] )
    L.append( [t[i],c[i]-1,0] )

L.sort()
#print(L)
ans=0
tmp=0

for i,(time, ch, sw) in enumerate(L):
    if sw==1:
        if f[ch]==False:
            tmp +=1
            #print(i,"record",tmp)
            f[ch]=True
            ans = max(ans,tmp)
    else:
        tmp -= 1
        #print(i,"stop",tmp)
        f[ch]=False
        #print(f)
   
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc080/tasks/abc080_d
# D - Recording
N,C = map(int,input().split())
s=[0]*N
t=[0]*N
c=[0]*N
L=[]
for i in range(N):
    s[i],t[i],c[i]= map(int,input().split())
    L.append( [s[i]-0.5,1] )
    L.append( [t[i],0] )

L.sort()
#print(L)
ans=0
tmp=0

for time, sw in L:
    if sw==1:
        tmp +=1
        ans = max(ans,tmp)
    else:
        tmp -= 1
    #print(time,tmp)
   
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc080/tasks/abc080_d
# D - Recording
N,C = map(int,input().split())
s=[0]*N
t=[0]*N
c=[0]*N
L=[]
for i in range(N):
    s[i],t[i],c[i]= map(int,input().split())
    L.append( [s[i],1] )
    L.append( [t[i],0] )

L.sort(key=lambda x:x[1],reverse=True)
L.sort(key=lambda x:x[0])
#print(L)
ans=0
tmp=0

for time, sw in L:
    if sw==1:
        tmp +=1
        ans = max(ans,tmp)
    else:
        tmp -= 1
    #print(time,tmp)
   
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    d1 = [0] * 100001
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        if d[s][c]:
            d1[s - 1] -= 1
            d1[s] += 1
        else:
            d[s][c] = 1
        if d[t][c]:
            d1[t - 1] -= 1
            d1[t] += 1
        else:
            d[t][c] = 1
        d1[s - 1] += 1
        d1[t] -= 1

    cur = 0
    r = 0
    for i1 in range(100000):
        t1 = sum(d[i1])
        t2 = d1[i1 + 1]
        if t1:
            t2 -= t1 // 2
        cur += t2
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    d1 = [0] * 100001
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        if d[s][c]:
            d[s][c] = 2
        else:
            d[s][c] = 1
        if d[t][c]:
            d[t][c] = 2
        else:
            d[t][c] = 1
        d1[s - 1] += 1
        d1[t] -= 1

    cur = 0
    r = 0
    for i1 in range(100000):
        t1 = sum(d[i1])
        t2 = d1[i1 + 1]
        if t1:
            t2 -= t1 // 2
        cur += t2
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    d1 = [0] * 100001
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        if d[s][c]:
            d[s][c] = 2
        else:
            d[s][c] = 1
        if d[t][c]:
            d[t][c] = 2
        else:
            d[t][c] = 1
        d1[s - 1] += 1
        d1[t] -= 1

    cur = 0
    r = 0
    for i1 in range(100001):
        t1 = sum(d[i1])
        t2 = d1[i1]
        if t1:
            t2 -= t1 // 2
        cur += t2
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        d[s - 1][c] += 1
        d[t - 1][c] -= 1

    cur = 0
    r = 0
    for i1 in range(100001):
        cur += sum(d[i1])
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        d[s - 1][c] += 1
        d[t][c] -= 1

    cur = 0
    r = 0
    for i1 in range(100001):
        cur += sum(d[i1])
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    # cs[0]とcs[-1]はindex error除け。
    cs = [0] * 100002
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        cs[s - 1] += 1
        cs[t] -= 1
    cur = 0
    r = 0
    for cse in cs:
        cur += cse
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()
stc = [LIST() for _ in range(N)]

cnt = [0]*(10**5 + 2)

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

cnt = list(accumulate(cnt))
print(max(cnt))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()
stc = [LIST() for _ in range(N)]

cnt = [0]*(10**5 + 2)

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

cnt = list(accumulate(cnt))
print(max(cnt))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
A = []
for _ in range(N):
    s,t,c = map(int,input().split())
    A.append([s,t,c])
A.sort()
cnt = 1
B = []
overlap = []
ans = 0
for i in range(N):
    if B: a = 0.5 if B[-1][2] ==A[i][2] else 0
    if not B:
        B.append(A[i])
    else:
        if B[-1][1]<=A[i][0]-a:
            B.pop()
            B.append(A[i])
            cnt = 1
            overlap = []
        else:
            if B[-1][1]<=A[i][1]:
                if not overlap or overlap[1]<=A[i][0]-a:
                    cnt = 2
                    overlap = [A[i][0],A[i][1]]
                else:
                    cnt += 1
                    overlap[1] = A[i][0]
                B.pop()
                B.append(A[i])
            else:
                if not overlap or overlap[1]<=A[i][0]-a:
                    cnt = 2
                    overlap = [A[i][0],A[i][1]]
                else:
                    cnt += 1
                    overlap[1] = A[i][0]
    ans = max(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
stc = [list(map(lambda x:2*int(x), input().split())) for _ in range(N)]

stc = sorted(stc, key=lambda x:(x[2], x[0], x[1]))
l = []
i = N-1
s, t, c = 0, 0, 0
while i >= 0:
    if stc[i][2] == stc[i-1][2] and stc[i][0] == stc[i-1][1]:
        s = stc[i-1][0]
        if t == 0:
            t = stc[i][1]
        c = stc[i][2]
    else:
        if s != 0:
            l += [[s, t, c]]
            s, t, c = 0, 0, 0
        else:
            l += [stc[i]]

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

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

print(max(imos))

Submission status: Wrong Answer

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

chs=[[] for i in range(31)]

for i in range(n):
    s,t,c=map(int,input().split())
    chs[c].append((s,t))

for q in range(C):
    ch=chs[q]
    ch.sort()
    new=[]
    if len(ch)<=1:
        continue
    else:
        now=ch[0]
        for i in range(1,len(ch)):
            if now[1]==ch[i][0]:
                now=(now[0],ch[i][1])
            else:
                new.append(now)
                now=ch[i]
        new.append(now)
        ch=new[:]

tim=[0 for i in range(200002)]

for ch in chs:
    for pro in ch:
        tim[pro[0]*2-1]+=1
        tim[pro[1]*2]-=1

cnt=0
ans=0
for i in range(len(tim)):
    cnt+=tim[i]
    ans=max(ans,cnt)
print(ans)

Submission status: Wrong Answer

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

ans = C
d = [list() for _ in range(C+1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    heapq.heappush(d[c], [s, t])

S = [0]*(10**5+1)
T = [0]*(10**5+1)

for i in range(C+1):
    if not d[i]:
        continue
    s, t = d[i][0]
    for j in range(1, len(d[i])):
        if t+1 >= d[i][j][0]:
            t = d[i][j][1]
        else:
            S[s] += 1
            T[t] += 1
            s, t = d[i][j]
    S[s] += 1
    T[t] += 1

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

Submission status: Wrong Answer

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

ans = C
d = [list() for _ in range(C+1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    heapq.heappush(d[c], [s, t])

S = [0]*(10**5+1)
T = [0]*(10**5+1)

for i in range(C+1):
    if not d[i]:
        continue
    s, t = d[i][0]
    for j in range(1, len(d[i])):
        if t == d[i][j][0]:
            t = d[i][j][1]
        else:
            S[s] += 1
            T[t] += 1
            s, t = d[i][j]
    S[s] += 1
    T[t] += 1

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

Submission status: Wrong Answer

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

MT = (10 ** 5 + 10)

memo = [[0] * C for _ in range(MT)]

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

ans = 0
cnt = 0
for i in range(MT):
    cnt += sum(memo[i])
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

MT = (10 ** 5 + 10)

memo = [[0] * C for _ in range(MT)]

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

ans = 0
cnt = 0
for i in range(15):
    cnt += sum(memo[i])
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

MT = (20 ** 5 + 10)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s*2] += 1 << (c - 1)
    memo_t[t*2+1] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, MT):
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt += 1
    ans = max(ans, cnt)
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt -= 1
print(ans)

Submission status: Wrong Answer

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

MT = (10 ** 5 + 10)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s] += 1 << (c - 1)
    memo_t[t] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, MT):
    cnt_s = 0
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt_s += 1
    cnt_t = 0
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt_t += 1

    ans = max(ans, cnt + cnt_s - max(cnt_t - cnt_s, 0))
    cnt = cnt + cnt_s - cnt_t
print(ans)

Submission status: Wrong Answer

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

MT = (10 ** 5 + 10)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s] += 1 << (c - 1)
    memo_t[t] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, MT):
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt += 1
    ans = max(ans, cnt)
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt -= 1
print(ans)

Submission status: Wrong Answer

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

MT = (10 ** 5 + 1)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s] += 1 << (c - 1)
    memo_t[t] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, MT):
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt += 1
    ans = max(ans, cnt)
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt -= 1
print(ans)

Submission status: Wrong Answer

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

MT = (10 ** 5 + 1)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s] += 1 << (c - 1)
    memo_t[t] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, MT):
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt += 1
    tmp =  cnt
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt -= 1
print(ans)

Submission status: Wrong Answer

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

MT = (10 ** 5 + 1)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s] += 1 << (c - 1)
    memo_t[t] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, 100):
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt += 1
    ans = max(ans, cnt)
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * 2 * (10 ** 5 + 1)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == 2 * s:
            table[t_ + 1] -= 1
        else:
            table[2 * s - 1] += 1

        table[2 * t + 1] -= 1
        t_ = 2 * t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * 2 * (10 ** 5 + 1)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == 2 * s:
            table[t_ + 1] -= 1
        else:
            table[2 * s - 1] += 1

        table[2 * t] -= 1
        t_ = 2 * t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()