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())
time=[0]*(10**5+1)
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]-1]+=1
	time[lis[i][1]]-=1
for i in range(10**5):
	time[i+1]+=time[i]
print(max(time))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
time=[0]*(2*(10**5)+2)
for i in range(n):
	s,t,c=map(int,input().split())
	time[s*2-1]+=1
	time[t*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+1)
for i in range(n):
	s,t,c=map(int,input().split())
	time[s-1]+=1
	time[t]-=1
for i in range(10**5):
	time[i+1]+=time[i]
print(max(time))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
time=[0]*(10**5+1)
for i in range(n):
	s,t,c=map(int,input().split())
	time[s-1]+=1
	time[t]-=1
for i in range(10**5-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)
for i in range(n):
	s,t,c=map(int,input().split())
	time[s-1]+=1
	time[t-1]-=1
for i in range(10**5-1):
	time[i+1]+=time[i]
print(max(time))

Submission status: Wrong Answer

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

li = [[] for _ in range(C)]
li2 = []

for s,t,c in stc:
    li[c-1].append((s,t))

#print(li)

"""
for i in range(C):
    if li[i]:
        li[i].sort()
        flag = False
        count = 0
        for j in range(len(li[i])-1):
            if li[i][j][1] == li[i][j+1][0]:
                if flag:
                    pass
                else:
                    flag = True
                    count = j
            else:
                if flag:
                    flag = False
                    li2.append((li[i][count][0]-0.5, li[i][j][1]))
                else:
                    li2.append((li[i][j][0]-0.5, li[i][j][1]))
        if flag:
            flag = False
            li2.append((li[i][count][0]-0.5, li[i][-1][1]))
        else:
            li2.append((li[i][-1][0]-0.5, li[i][-1][1]))
"""

for i in range(C):
    if li[i]:
        li[i].sort()
        flag = False
        count = 0
        count2 = 0
        tmp = 0
        li_tmp = []
        while li[i]:
            #print(li[i])
            for j in range(len(li[i])-1):
                if li[i][tmp][1] == li[i][j+1][0]:
                    if flag:
                        tmp = j+1
                    else:
                        flag = True
                        count = j
                        tmp = j+1
                else:
                    if flag:
                        li_tmp.append((li[i][j+1][0], li[i][j+1][1]))
                    else:
                        li2.append((li[i][j][0]-0.5, li[i][j][1]))
            if flag:
                flag = False
                li2.append((li[i][count][0]-0.5, li[i][tmp][1]))
            else:
                li2.append((li[i][-1][0]-0.5, li[i][-1][1]))
            li[i] = copy.copy(li_tmp)
            li_tmp = []

#print(li2)

li2.sort(key = lambda x: x[1])
ans = 0
li3 = []

while li2:
    count = 0
    ans += 1
    for i in range(len(li2)):
        if li2[i][0] > count:
            count = li2[i][1]
        else:
            li3.append(li2[i])
    li2 = copy.copy(li3)
    li3 = []

print(ans)

Submission status: Wrong Answer

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

li = [[] for _ in range(C)]
li2 = []

for s,t,c in stc:
    li[c-1].append((s,t))

for i in range(C):
    if li[i]:
        li[i].sort()
        flag = False
        count = 0
        for j in range(len(li[i])-1):
            if li[i][j][1] == li[i][j+1][0]:
                if flag:
                    pass
                else:
                    flag = True
                    count = j
            else:
                if flag:
                    flag = False
                    li2.append((li[i][count][0]-0.5, li[i][j][1]))
                else:
                    li2.append((li[i][j][0]-0.5, li[i][j][1]))
        if flag:
            flag = False
            li2.append((li[i][count][0]-0.5, li[i][-1][1]))
        else:
            li2.append((li[i][-1][0]-0.5, li[i][-1][1]))

li2.sort(key = lambda x: x[1])
ans = 0
li3 = []

while li2:
    count = 0
    ans += 1
    for i in range(len(li2)):
        if li2[i][0] > count:
            count = li2[i][1]
        else:
            li3.append(li2[i])
    li2 = copy.copy(li3)
    li3 = []

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort(key=lambda x: x[2])
# print(stc)
lst=[0]*(10**5+5)
for i in range(len(stc)):
    s,t,c=stc[i]
    if i!=0 and stc[i-1][2]==c and stc[i-1][1]==s:
        s+=1
    for j in range(s-1,t):
        lst[j]+=1
# print(lst)
print(max(lst))

Submission status: Wrong Answer

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
lst=[0]*(pow(10,5)+5)
for i in range(len(stc)):
    s,t,c=stc[i]
    for j in range(s-1,t):
        lst[j]+=1
print(max(lst))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
imos = [0]*(100005)
for _ in range(N):
    s, t, c = map(int, input().split())
    s -= 1
    t -= 1
    imos[s] += 1
    imos[t+1] -= 1
cumulative = [imos[0]]
for value in imos[1:]:
    cumulative.append(cumulative[-1] + value)
print(max(cumulative))

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

#heapq
import heapq
class Reverse:
    def __init__(self, val):
        self.val = val
        
    def __lt__(self, other):
        return self.val > other.val
        
    def __repr__(self):
        return repr(self.val)
    
class Heapq:
    def __init__(self, arr, desc = False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        if self.desc: return heapq.heappop(self.hq).val
        else: return heapq.heappop(self.hq)
 
    def push(self, a):
        if self.desc: heapq.heappush(self.hq, Reverse(a))
        else: heapq.heappush(self.hq, a)
 
    def top(self):
        if self.desc: return self.hq[0].val
        else: return self.hq[0]

from operator import itemgetter
def index_sort(A):
    A_sort = sorted(enumerate(A),key=itemgetter(1))
    index = [a[0] for a in A_sort]
    sorted_A = [a[1] for a in A_sort]
    return index, sorted_A

N,C = II()
s,t,c = Line(N,3)

index, _ = index_sort(s)
s = [s[i] for i in index]
t = [t[i] for i in index]

h = Heapq([10**6])
ans = 0
for i in range(N):
    if h.top() < s[i]:
        h.pop()
        h.push(t[i])
    else:
        h.push(t[i])
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])
 
for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]
 
                if end!=lists[i][j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]

 
        lists[i]=sublists

 
startlists={i:0 for i in range(100001)}
endlists={i:0 for i in range(100002)}
 
for i in range(31):
    if len(lists[i])>=1:
        for some in lists[i]:
            startlists[some[0]]+=1
            endlists[some[1]+1]+=1
 
for i in range(1,100001):
    startlists[i]=startlists[i]+startlists[i-1]
    endlists[i]=endlists[i]+endlists[i-1]
 
 
maxi=0
for i in range(100001):
    maxi=max(maxi,startlists[i]-endlists[i])
print(maxi)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                if end!=lists[i][j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]
                if j==len(lists[i])-1:
                    sublists.append((start,end))

        lists[i]=sublists



startlists={i:0 for i in range(100001)}
endlists={i:0 for i in range(100002)}

for i in range(31):
    if len(lists[i])>=1:
        for some in lists[i]:
            startlists[some[0]]+=1
            endlists[some[1]+1]+=1

for i in range(1,100001):
    startlists[i]=startlists[i]+startlists[i-1]
    endlists[i]=endlists[i]+endlists[i-1]


maxi=0
for i in range(100001):
    maxi=max(maxi,startlists[i]-endlists[i])
print(maxi)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                if end!=lists[i][j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]
                if j==len(lists[i])-1:
                    sublists.append((start,end))

        lists[i]=sublists


startlists={i:0 for i in range(100001)}
endlists={i:0 for i in range(100001)}

for i in range(31):
    if len(lists[i])>=1:
        for some in lists[i]:
            startlists[some[0]]+=1
            endlists[some[1]]+=1
for i in range(1,100001):
    startlists[i]=startlists[i]+startlists[i-1]
    endlists[i]=endlists[i]+endlists[i-1]


maxi=0
for i in range(100000):
    maxi=max(maxi,startlists[i+1]-endlists[i])
print(maxi)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                if end!=lists[i][j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]
                if j==len(lists[i])-1:
                    sublists.append((start,end))

        lists[i]=sublists


startlists={i:0 for i in range(100001)}
endlists={i:0 for i in range(100001)}

for i in range(31):
    if len(lists[i])>=1:
        for some in lists[i]:
            startlists[some[0]-1]+=1
            endlists[some[1]]+=1
for i in range(1,100001):
    startlists[i]+=startlists[i-1]
    endlists[i]+=endlists[i-1]


maxi=0
for i in range(100001):
    maxi=max(maxi,startlists[i]-endlists[i])
print(maxi)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                if end!=lists[i][j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]
##この上もあってそう
                if end!=lists[i][j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])


for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

Submission status: Wrong Answer

Solution code:
import itertools
n,c = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[0])
# いもす法
x=[0]*(10**5+5)
for i in range(n):
    x[a[i][0]]+=1
    x[a[i][1]+1]-=1

x = itertools.accumulate(x)

print(max(x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
g=[[0]*3 for i in range(n)]
for i in range(n):
  g[i]=list(map(int,input().split()))
T=[0]*(10**5+3)
for i in range(n):
  T[g[i][0]]+=1
  T[g[i][1]+1]-=1
ans=0
a=0
for i in range(len(T)):
  a=a+T[i]
  if a>ans:
    ans=a
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,c = inm()
a = []
for i in range(n):
    s,t,c = inm()
    a.append((t,s,c))
a.sort()

h = {}  # h[(t,c)] = s
for z in a:
    t,s,c = z
    if (s,c) in h:
        s0 = h[(s,c)]
        del h[(s,c)]
        h[(t,c)] = s0
    else:
        h[(t,c)] = s

a = []
for z in h:
    t,c = z
    s = h[z]
    a.append((t,s,c))

a.sort()
n = len(a)
nu = 0
ut = [-1]*n
uc = [-1]*n
for i in range(n):
    t,s,c = a[i]
    for j in range(nu+1):
        if ut[j] + (0 if uc[j]==c else 1) <= s:
            ut[j] = t
            uc[j] = c
            #ddprint("t {} s {} c {} j {}".format(t,s,c,j))
            #ddprint(ut)
            #ddprint(uc)
            if j==nu:
                nu += 1
            break
print(nu)

Submission status: Wrong Answer

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,c = inm()
a = []
for i in range(n):
    s,t,c = inm()
    a.append((t,s,c))
a.sort()
nu = 0
ut = [-1]*n
uc = [-1]*n
for i in range(n):
    t,s,c = a[i]
    for j in range(nu+1):
        if ut[j] + (0 if uc[j]==c else 1) <= s:
            ut[j] = t
            uc[j] = c
            if j==nu:
                nu += 1
            break
print(nu)

Submission status: Wrong Answer

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,c = inm()
a = []
for i in range(n):
    s,t,c = inm()
    a.append((t,s,c))
a.sort()
nu = 0
ut = [-1]*n
uc = [-1]*n
for i in range(n):
    t,s,c = a[i]
    for j in range(nu+1):
        if ut[j] + (0 if uc[j]==c else 1) <= s:
            ut[j] = t
            uc[j] = s
            if j==nu:
                nu += 1
            break
print(nu)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n, c = map(int, input().split())
D = [0]*(10**5+1)
for _ in range(n):
  s, t, c = map(int, input().split())
  D[s-1] += 1
  D[t] -= 1
A = accumulate(D)
print(max(A))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N, C = map(int, input().split())
R = [0] * (10**5+1)
for _ in range(N):
    s, t, c = map(int, input().split())
    R[s-1] += 1
    R[t] -= 1
print(max(list(accumulate(R))))

Submission status: Wrong Answer

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

time = list()
for i in range(0, n):
    s, t, c = map(int, input().split(" "))
    time.append((s, t, c))

time_sorted = sorted(time, key=lambda x: (x[2], x[1]))

time_joined = list()
prev = None
for current in time_sorted:
    if prev is None:
        prev = current

    elif prev[2] == current[2] and prev[1] == current[0]:
        prev = (prev[0], current[1], current[2])

    else:
        time_joined.append(prev)
        prev = current

# time_joined.append(prev)
print(time_joined)

time_list = list()
for s, t, c in time_joined:
    time_list.append((s - 0.5, "s"))
    time_list.append((t, "t"))

time_list_sorted = sorted(time_list, key=lambda x: x[0])

current = 0
ans = 0

for t, s in time_list_sorted:
    if s == "s":
        current += 1
        ans = max(ans, current)
    else:
        current -= 1

print(ans)

Submission status: Wrong Answer

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

time = list()
for i in range(0, n):
    s, t, c = map(int, input().split(" "))
    time.append((s - 0.5, "s"))
    time.append((t, "t"))

time_sorted = sorted(time, key=lambda x: x[0])

current = 0
ans = 0

for t, s in time_sorted:
    if s == "s":
        current += 1
        ans = max(ans, current)
    else:
        current -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
p = [list(map(int,input().split())) for i in range(N)]
p.sort()
ch = [[0,0] for i in range(C+1)]
p_true = []
for i in range(N):
  [s,t,c] = p[i]
  if ch[c][1] == s:
    ch[c][1] = t
  elif ch[c] == [0,0]:
    ch[c] = [s,t]
  else:
    p_true.append([ch[c][0],ch[c][1],c])
    ch[c] = [s,t]
for i in range(1,C+1):
  if ch[i] != [0,0]:
    p_true.append([ch[i][0],ch[i][1],i])
p_true.sort()

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
p.sort()
res = [0 for _ in range(100005)]
res0 = [[0,0] for _ in range(c)]
np = []
for s,t,c in p:
    if res0[c-1][0] == 0:
        res0[c-1] = [s,t]
    elif res0[c-1][1] ==s:
        res0[c-1][1] =t
    else:
        np.append(res0[c-1][:])
        res0[c-1]=[s,t]
for sres0 in res0:
    np.append(sres0)

for s,t in np:
    res[s] += 1
    res[t+1]-=1

ress = [0]
for i in range(100005):
    ress.append(ress[-1]+res[i])

print(max(ress))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
res = [0 for _ in range(100005)]
for s,t,c in p:
    res[s] += 1
    res[t+1]-=1

ress = [0]
for i in range(100005):
    ress.append(ress[-1]+res[i])

print(max(ress))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
p.sort()
res = []
for s,t,c in p:
    flag = 1
    for i in range(len(res)):
        if res[i][1] < s:
            res[i][1]=t
            flag = 0
            break
    if flag ==1:
        res.append([s,t])
    res.sort(key=lambda x: x[1],reverse=True)

print(len(res))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline


n, c = map(int, input().split())
tv_guide = np.zeros(10**5+1, dtype=np.int)

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

print(tv_guide.max())

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
import sys
input = sys.stdin.buffer.readline

def main():
    N,C = map(int,input().split())
    _ch = []
    for _ in range(N):
        s,t,c = map(int,input().split())
        _ch.append((s,t,c-1))
        
    time = [[0,0] for _ in range(C)]
    ch = []
    for i in range(N):
        s,t,c = _ch[i]
        if (s != time[c][1]):
            if time[c][1] != 0:
                ch.append((time[c][0]-0.5,time[c][1],c))
            time[c] = [s,t]
        else:
            time[c][1] = t
        
    for i in range(C):
        if time[i][1] != 0:
            ch.append((time[i][0]-0.5,time[i][1],i))
            
    ch.sort(key = itemgetter(0,1))
    num = len(ch)-1
    use = [ch[0][1]]
    for i in range(num):
        i += 1
        s,t,c = ch[i]
        A = len(use)
        for j in range(A):
            if use[j] < s:
                use[j] = t
                break
            if (use[j] > s and j == A-1):
                use.append(t)
    
    print(len(use))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    for i in range(N):
        data.append(list(map(int,input().split())))

    data_np = np.array(data).reshape(N,3)

    max_time = max(data_np[:,1])
    schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            if start+j-1<0:continue
            schedule[start+j-1][channel] = 1

#    for c in range(C):
#        for t in range(max_time):
#            if t==0:continue
#            if schedule[t][c]==1 and schedule[t-1][c]==0:
#                schedule[t-1][c]=1

    #max_N =0
    #for t in range(max_time):
    #    sum_of_ch = sum(schedule[t])

    temp = list(map(sum,list(schedule)))
    max_N = max(temp)


    #    if sum_of_ch>max_N:
    #        max_N = int(sum_of_ch)
    print(max_N)







main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    for i in range(N):
        data.append(list(map(int,input().split())))

    data_np = np.array(data).reshape(N,3)

    max_time = max(data_np[:,1])
    schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            schedule[start+j][channel] = 1

    for c in range(C):
        for t in range(max_time):
            if t==0:continue
            if schedule[t][c]==1 and schedule[t-1][c]==0:
                schedule[t-1][c]=1

    max_N =0
    for t in range(max_time):
        sum_of_ch = sum(schedule[t])

        if sum_of_ch>max_N:
            max_N = int(sum_of_ch)
    print(max_N)







main()

Submission status: Wrong Answer

Solution code:
import heapq
from operator import itemgetter

n,c = map(int, input().split())
stc = sorted([list(map(int, input().split())) for i in range(n)],key=itemgetter(1))
ans = 1
hq = [stc[0][1]]
for s,t,c in stc[1:]:
  if s > hq[0]:
    heapq.heappushpop(hq,t)
  else:
    heapq.heappush(hq,t)
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC080 D - Recording
N,C=map(int,input().split())
total=[0]*(10**5+1)
channel=[[0]*(10**5+1) for i in range(C)]

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

# for i in range(C):
#     total[0]+=channel[i][0]

for i in range(10**5+1):
    if i!=0:
        total[i]+=total[i-1]
    for j in range(C):
        total[i]+=channel[j][i]
print(max(total))

Submission status: Wrong Answer

Solution code:
# ABC080 D - Recording
N,C=map(int,input().split())
total=[0]*(10**5+2)
channel=[[0]*(10**5+2) for i in range(C)]

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

for i in range(C):
    total[0]+=channel[i][0]

for i in range(1,(10**5+2)):
    total[i]+=total[i-1]
    for j in range(C):
        total[i]+=channel[j][i]
print(max(total))

Submission status: Wrong Answer

Solution code:
# ABC080 D - Recording
N,C=map(int,input().split())
total=[0]*(10**5+2)
channel=[[0]*(10**5+2) for i in range(C)]

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

for i in range(C):
    total[0]+=channel[i][0]

for i in range(1,(10**5+1)):
    total[i]+=total[i-1]
    for j in range(C):
        total[i]+=channel[j][i]
print(max(total))

Submission status: Wrong Answer

Solution code:
# ABC080 D - Recording
N,C=map(int,input().split())
total=[0]*(10**5+1)
channel=[[0]*(10**5+1) for i in range(C)]

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

for i in range(C):
    total[0]+=channel[i][0]

for i in range(1,(10**5+1)):
    total[i]+=total[i-1]
    for j in range(C):
        total[i]+=channel[j][i]
print(max(total))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
C = [[] for i in range(M)]
for i in range(N):
    l, r, c = MAP()
    c -= 1
    C[c].append((l, r))

# 同チャンネルで連続する区間をまとめる
LR = []
for i in range(M):
    if C[i]:
        C[i].sort()
        LR.append(C[i][0])
        for j in range(1, len(C[i])):
            l1, r1 = C[i][j-1]
            l2, r2 = C[i][j]
            if r1 == l2:
                LR.pop()
                LR.append((l1, r2))
            else:
                LR.append((l2, r2))

# いもす法
MAX = 10 ** 5
imos = [0] * (MAX+7)
for l, r in LR:
    imos[l] += 1
    imos[r+1] -= 1
imos = list(accumulate(imos))
print(max(imos))