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
import numpy as np

n, c = list(map(int, sys.stdin.readline().strip().split(" ")))

start_list = []
end_list = []
c_list = []
time_set = set()
min_time = 10**5
max_time = 0
for _ in range(n):
    s, t, c = list(map(int, sys.stdin.readline().strip().split(" ")))
    start_list.append(s)
    end_list.append(t)
    c_list.append(c)
    max_time = max(t, max_time)
    min_time = min(s, min_time)
    time_set.add(s-0.5)
    time_set.add(t)

start_list = np.array(start_list)
end_list = np.array(end_list)
c_list = np.array(c_list)

index_list = np.argsort(start_list)
start_list = start_list[index_list]
end_list = end_list[index_list]
c_list = c_list[index_list]

current_channel = []
current_tv = []
top = 0
res = 0

#for i in range((max_time - min_time + 1) * 2):
    #t = 0.5 * i + (min_time - 0.5)
for t in time_set:
    while(top < n) and (start_list[top] - 0.5 == t):
        if c_list[top] not in current_channel:
            current_tv.append(top)
        top+=1
    tmp = list(current_tv)
    current_channel = []
    for index in tmp:
        if (end_list[index] == t):
            current_tv.remove(index)
        else:
            if c_list[index] not in current_channel:
                current_channel.append(c_list[index])
    res = max(res, len(current_channel))
            
print(res)

Submission status: Wrong Answer

Solution code:
def inpl(): return tuple(map(int, input().split()))

N, C = inpl()
P = sorted([inpl() for _ in range(N)])

R = [[[-1, 0, -1]] for _ in range(30)]
for s, t, c in P:
    i = 0
    # 連続録画を探す
    sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s]
    if sr:
        R[min(sr)].append([s, t, c])
    else:
        r = [i for i in range(30) if R[i][-1][1] <= s - 0.5]
        R[min(r)].append([s, t, c])

for i in range(30):
    if len(R[i]) == 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
n, c_no = list(map(int, input().split()))
s, t = [], []
c = []
for i in range(c_no):
    c.append([])
for i in range(n):
    stc = list(map(int, input().split()))
    c[stc[2] - 1].append([stc[0], stc[1]])
a = 10**5*[0]
for i in range(len(c)):
    tmp = 10**5*[0]
    c[i].sort()
    for j in range(len(c[i])):
        tmp = c[i][j][0]
        for k in range(c[i][j][1] - c[i][j][0] + 1):
            if(a[c[i][j][0] + k - 1] != tmp):
                a[c[i][j][0] + k - 1] += 1
print(max(a))

Submission status: Wrong Answer

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

table=[[] for i in range(C)]
for _ in range(N):
  s,t,c=map(int,raw_input().split(' '))
  table[c-1].append((s,t))

x=0
for cm in range(C):
  for i in range(len(table[cm])):
    s,t = table[cm][i]
    tmp=0
    for c in range(C):
      if cm==c:
        continue
      for j in range(len(table[c])):
        st,tt=table[c][j]
      
        if st<=s<=tt or st<=t<=tt:
          tmp+=1

    x=max(x,tmp)

print x+1

Submission status: Wrong Answer

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

T=0
for i in A:
    T=max(i[1],T)
timelist=[0 for _ in range((1+T)*2)]
for item in A:
    starttime=item[0]
    endtime=item[1]
    for time in range(starttime*2-2,endtime*2,2):
        timelist[time]+=1
        timelist[time+1]+=1
print(max(timelist))

Submission status: Wrong Answer

Solution code:
import sys

line = sys.stdin.readline()
N, C = [int(x) for x in line.strip().split()]

STC = []

for i in range(N):
    line = sys.stdin.readline().strip()
    xs = [int(x) for x in line.split()] + [0]
    STC.append(xs)

STC.sort(key=(lambda x:(x[1],x[2])))

# print(STC)

r = 0
n = 0
while n < N:
    t = 0
    c = 0
    for x in STC:
        if x[3] == 1:
            continue
        xt = x[0]
        if x[2] != c:
            xt -= 0.5
        if t <= xt:
            # print(r, t, c, x)
            t = x[1]
            c = x[2]
            x[3] = 1
            n += 1
    r += 1

print(r)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n, c = map(int, input().split())
    c_info = [[int(i) for i in input().split()] for _ in range(n)]
    c_info.sort(key=lambda x: (x[2], x[0]))
    info = []
    cnt = 0
    
    while cnt < n:
        if cnt == n - 1:
            info.append(c_info[cnt])
            break
        print(c_info[cnt], c_info[cnt + 1])
        if c_info[cnt][1] == c_info[cnt + 1][0] and c_info[cnt][2] == c_info[cnt + 1][2]:
            tc = c_info[cnt][2]
            t = [c_info[cnt][0], c_info[cnt + 1][1], tc]
            cnt += 1
            while cnt < n - 1 and t[1] == c_info[cnt + 1][0] and tc == c_info[cnt + 1][2]:
                t = [t[0], c_info[cnt + 1][1], tc]
                cnt += 1
            info.append(t)
            if cnt == n - 1:
                break
        else:
            info.append(c_info[cnt])
        cnt += 1

    tarr = [0] * (2 + 10 ** 5)
    for elem in info:
       tarr[elem[0]] += 1
       tarr[elem[1] + 1] -= 1
    
    ans = 1
    tans = 0
    for elem in tarr:
        tans += elem
        ans = max(ans, tans)
    print(ans)

if __name__=="__main__":
    solve()

Submission status: Wrong Answer

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

ss = [0] * N
tt = [0] * N
cc = [0] * N

for n in range(N):
    ss[n], tt[n], cc[n] = map(int, input().split(' '))

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

for n in range(N):
    timeline[ss[n] - 1] += 1
    timeline[tt[n]] -= 1

max_ = 0
stack = 0
for t in timeline:
    stack += t
    if stack > max_:
        max_ = stack

print(max_)

Submission status: Wrong Answer

Solution code:
import heapq

heap = []
rec = 1

N,C = map(int,input().split(" "))
info = [(0,0,0)] * N

for i in range(N):
	a,b,c = map(int,input().split(" "))
	info[i] = (a,b,c)

info.sort()

heapq.heappush(heap,info[0][1])
for i in range(1,N):
	if heap[0] <= info[i][0] - 0.5:
		heapq.heappop(heap)
		heapq.heappush(heap,info[i][1])

	else:
		rec += 1
		heapq.heappush(heap,info[i][1])

print(rec)

Submission status: Wrong Answer

Solution code:
def inpl(): return tuple(map(int, input().split()))

N, C = inpl()
P = sorted([inpl() for _ in range(N)])

R = [[[-1, 0, -1]] for _ in range(30)]
for s, t, c in P:
    i = 0
    # 連続録画を探す
    sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][2] <= s]
    if sr:
        R[min(sr)].append([s, t, c])
    else:
        r = [i for i in range(30) if R[i][-1][2] <= s - 0.5]
        R[min(r)].append([s, t, c])

for i in range(30):
    if len(R[i]) == 1:
        print(i+1)
        break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n, c = map(int, input().split())
    c_info = [[int(i) for i in input().split()] for _ in range(n)]
    c_info.sort(key=lambda x: (x[2], x[0]))
    info = []
    cnt = 0
    while cnt < n:
        if cnt == n - 1:
            info.append(c_info[cnt])
            break
        if c_info[cnt][1] == c_info[cnt + 1][0] and c_info[cnt][2] == c_info[cnt + 1][2]:
            tc = c_info[cnt][2]
            t = [c_info[cnt][0], c_info[cnt + 1][1], tc]
            cnt += 1
            while cnt < n - 1 and t[1] == c_info[cnt + 1][0] and tc == c_info[cnt + 1][2]:
                t = [t[1], c_info[cnt + 1][1], tc]
                cnt += 1
            info.append(t)
            if cnt == n - 1:
                break
        else:
            info.append(c_info[cnt])
        cnt += 1

    tarr = [0] * (2 + 10 ** 5)
    for elem in info:
       tarr[elem[0]] += 1
       tarr[elem[1] + 1] -= 1
    
    ans = 1
    tans = 0
    for elem in tarr:
        tans += elem
        ans = max(ans, tans)
    print(ans)

if __name__=="__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n, c = list(map(int, sys.stdin.readline().strip().split(" ")))

start_list = []
end_list = []
c_list = []
min_time = 10**5
max_time = 0
for _ in range(n):
    s, t, c = list(map(int, sys.stdin.readline().strip().split(" ")))
    start_list.append(s)
    end_list.append(t)
    c_list.append(c)
    max_time = max(t, max_time)
    min_time = min(s, min_time)

start_list = np.array(start_list)
end_list = np.array(end_list)
c_list = np.array(c_list)

index_list = np.argsort(start_list)
start_list = start_list[index_list]
end_list = end_list[index_list]
c_list = c_list[index_list]

current_channel = []
current_tv = []
top = 0
res = 0

for i in range((max_time - min_time) * 2 + 1):
    t = 0.5 * i + min_time
    while(top < n) and (start_list[top] - 0.5 == t):
        if c_list[top] not in current_channel:
            current_tv.append(top)
        top+=1
    tmp = list(current_tv)
    current_channel = []
    for index in tmp:
        if (end_list[index] == t):
            current_tv.remove(index)
        else:
            if c_list[index] not in current_channel:
                current_channel.append(c_list[index])
    res = max(res, len(current_channel))
            
print(res)

Submission status: Wrong Answer

Solution code:
import sys

line = sys.stdin.readline()
N, C = [int(x) for x in line.strip().split()]

STC = []

for i in range(N):
    line = sys.stdin.readline().strip()
    xs = tuple([int(x) for x in line.split()])
    STC.append(xs)

stc = STC[:]
stc.sort(key=(lambda x:(x[1],x[2])))

#print(stc)

r = 0
while stc:
    t = 0
    c = 0
    for x in stc[:]:
        xt = x[0]
        if x[2] != c:
            xt -= 0.5
        if t <= xt:
            # print(r, t, c, x)
            t = x[1]
            c = x[2]
            stc.remove(x)
    r += 1

print(r)

Submission status: Wrong Answer

Solution code:
from heapq import heappop as pop, heappush as push

peak, curr = 0, 0

stuff = []
n, c = map(int, raw_input().split())
for _ in xrange(n):
  stuff.append(map(float, raw_input().split()))
  stuff[-1][-1] = int(stuff[-1][-1]) - 1
  
stuff = sorted(stuff)
has_camera = [False] * c
ending = []
for st, end, ch in stuff:
  while ending and ending[0][0] <= st - 0.5:
    _, cch = pop(ending)
    has_camera[cch] = False
    curr -= 1
  if not has_camera[ch]:
    curr += 1
  push(ending, (end, ch))
  peak = max(peak, curr)
  
print peak

Submission status: Wrong Answer

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

MAX_N = 10**5+3
imos = [0] * MAX_N
for c in range(C):
    cont = False
    for i,(s,t) in enumerate(ps[c]):
        if not cont:
            imos[s-1] += 1
        if i < len(ps[c])-1 and t == ps[c][i+1][0]:
            cont = True
        else:
            imos[t] -= 1
            cont = False

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

Submission status: Wrong Answer

Solution code:
n,c = map(int,input().split())
table = [0 for i in range(100010)]
table2 = [[] for i in range(100010)]
count = 0
while(count < n):
    count += 1
    s,t,c2 = map(int,input().split())
    cou2 = s
    if c2 in table2[s-1]:
        cou2 += 1
    while(cou2 <= t):
        table2[cou2].append(c2)
        table[cou2] = table[cou2]+ 1
        cou2 += 1

print(max(table))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
channel=[tuple(map(int,input().split())) for i in range(N)]
channel=sorted(channel,key=lambda cha: cha[0])

n=0
while(channel!=[]):
    c=[]
    n+=1
    pro=channel[0]
    channel.remove(pro)
    for i in channel:
        if i[0]>pro[1]:
            pro=i
        else:
            c.append(i)
    channel=c
print(n)

Submission status: Wrong Answer

Solution code:
n,c = map(int,input().split())
table = [0 for i in range(100010)]
count = 0
while(count < n):
    count += 1
    s,t,c2 = map(int,input().split())
    cou2 = s
    while(cou2 <= t):
        table[cou2] = table[cou2]+ 1
        cou2 += 1

print(max(table))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

periods = [0] * (2 * 10 ** 5)
for s, t, c in TVs:
    periods[s * 2 - 2: t * 2 - 1 + 1] = list(map(lambda x: x + 1, periods[s * 2 - 2: t * 2 - 1 + 1]))

print(max(periods))

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

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

s = [0] * n
t = [0] * n
chan = [0] * n
for i in range(n):
    s[i], t[i], chan[i] = list(map(int, input().split()))

length_double = 2 * (max(t)+1)

recording_num = [0] * length_double
# tt = [0] * length_double
for i in range(1, c+1):
    tt = [0] * length_double

    for j in range(n):
        if chan[j] == i:
            tt[s[j]*2-1] += 1
            tt[t[j]*2] -= 1
    
    for j in range(1, length_double):
        tt[j] += tt[j-1]
    for j in range(length_double):
        if tt[j] > 0:
            recording_num[j] += 1
    # print(tt)

ans = max(recording_num)
print(ans)
# print(recording_num)

Submission status: Time Limit Exceeded

Solution code:
n,c=map(int,input().split())
stc=[list(map(int,input().split())) for _ in range(n)]
cs_dc={}
dc={}
for s,t,c in stc:
  if c in dc:
    dc[c][s]+=1
    dc[c][t]-=1
  else:
    dc[c]=[0]*(10**5+2)
    dc[c][s]+=1
    dc[c][t]-=1
    cs_dc[c]=[0]*(10**5+2)

for i in range(10**5+1):
  for ci in dc:
    cs_dc[ci][i+1]=cs_dc[ci][i]+dc[ci][i+1]
ans=0
for i in range(10**5+1):
  tmp=0
  for ci in dc:
    tmp+=max(cs_dc[ci][i:i+2])
  ans=max(ans,tmp)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, _ = map(int, input().split())
CST = {} # {c:[max_t, [s,t],...[,]]}
for i in range(n):
    s, t, c = map(int, input().split())
    if c in CST: CST[c] += [[s,t]]
    else: CST[c] = [t, [s,t]]
    CST[c][0] = max(CST[c][0], t)
ans = 0
R = [0]*200002
for c, ST in CST.items():
    mx_t = ST[0]*2+2
    TZ = [0]*mx_t
    for s,t in ST[1:]:
        TZ[2*s - 1] += 1
        TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0:
            R[i+1] += 1
            if ans < R[i+1]: ans = R[i+1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, _ = map(int, input().split())
CST = {} # {c:[max_t, [s,t],...[,]]}
for i in range(n):
    s, t, c = map(int, input().split())
    if c in CST: CST[c] += [[s,t]]
    else: CST[c] = [t, [s,t]]
    CST[c][0] = max(CST[c][0], t)
ans = 0
R = [0]*200002
for c, ST in CST.items():
    mx_t = ST[0]*2+2
    TZ = [0]*mx_t
    for s,t in ST[1:]:
        TZ[2*s - 1] += 1
        TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
        if ans < R[i+1]: ans = R[i+1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, _ = map(int, input().split())
CST = {} # {c:[max_t, [s,t],...[,]]}
for i in range(n):
    s, t, c = map(int, input().split())
    if c in CST: CST[c] += [[s,t]]
    else: CST[c] = [t, [s,t]]
    CST[c][0] = max(CST[c][0], t)
R = [0]*200002
for c, ST in CST.items():
    mx_t = ST[0]*2+2
    TZ = [0]*mx_t
    for s,t in ST[1:]:
        TZ[2*s - 1] += 1
        TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))

Submission status: Time Limit Exceeded

Solution code:
n, _ = map(int, input().split())
CST = {} # {c:[[s,t],...]}
for i in range(n):
    s, t, c = map(int, input().split())
    if c in CST: CST[c] += [[s,t]]
    else: CST[c] = [[s,t]]
mx_t = 200002
R = [0]*mx_t
for c, ST in CST.items():
    TZ = [0]*mx_t
    for s,t in ST:
        TZ[2*s - 1] += 1
        TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))

Submission status: Time Limit Exceeded

Solution code:
n, c = map(int, input().split())
S, T, C = [], [], []
for i in range(n):
    s, t, x = map(int, input().split())
    S.append(s)
    T.append(t)
    C.append(x)
mx_t = 200002
R = [0]*mx_t
for cc in range(1, c+1):
    TZ = [0]*mx_t
    for i in range(n):
        if C[i] == cc:
            TZ[2*S[i] - 1] += 1
            TZ[2*T[i]] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))

Submission status: Time Limit Exceeded

Solution code:
N, C = map(int, input().split())
STC = [[*map(int, input().split())] for _ in range(N)]
mx_t = 200002
R = [0]*mx_t
for cc in range(1, C+1):
    TZ = [0]*mx_t
    for s,t,c in STC:
        if c == cc:
            TZ[2*s - 1] += 1
            TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))

Submission status: Time Limit Exceeded

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections
def main():

    N, C = map(int, input().split())
    d = collections.defaultdict(list)

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

    for c in d:
        d[c].sort()
        lv = []
        for i in range(len(d[c])):
            if i == 0:
                lv.append(d[c][i])
            else:
                if lv[-1][1] == d[c][i][0]:
                    lv[-1][1] = d[c][i][1]
                else:
                    lv.append(d[c][i])
        d[c] = lv

    # print(d)
    index = dict()
    for c in d: index[c] = 0
    bound = max([d[c][-1][1] for c in d])
    ans = 0
    for i in range(1, bound + 1):
        cnt = 0
        for c in d:
            while index[c] < len(d[c]) and d[c][index[c]][1] < i:
                index[c] += 1
            if index[c] < len(d[c]) and d[c][index[c]][0] <= i <= d[c][index[c]][1]:
                cnt += 1
        # print(i, cnt)
        ans = max(ans, cnt)
    return ans


if __name__ == '__main__':
    print(main())

Submission status: Time Limit Exceeded

Solution code:
n,C = map(int,input().split())
INF = float("INF")
ch = [[0]*(200001) for _ in range(C)]
m = 0
for _ in range(n):
    s,t,c = map(int,input().split())
    s = s*2-1
    t *= 2
    c -= 1
    ch[c][s] += 1
    ch[c][t] -= 1
    m = max(m,t)

cnt = [0]*(m+1)
for c in range(C):
    for i in range(1,m+1):
        ch[c][i] += ch[c][i-1]
        if ch[c][i-1] == 0 and ch[c][i] > 0: cnt[i] += 1
        if ch[c][i-1] > 0 and ch[c][i] == 0: cnt[i] -= 1

for i in range(1,m+1): cnt[i] += cnt[i-1]
print(max(cnt))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,C = [int(_n) for _n in input().split()]
    progs = [[] for _ in range(C)]
    times = set()
    for i in range(N):
        s,t,c = [int(_n) for _n in input().split()]
        c -= 1
        progs[c].append((s,t))
        times = times.union([s,t])
    times = list(times)
    times.sort()
    rev_times = {}
    for i,t in enumerate(times):
        rev_times[t] =i
    progs2 = []
    for i in range(C):
        p = progs[i]
        if len(p) == 0:
            continue
        p.sort(key = lambda x:x[0])
        res = []
        start = p[0][0]
        last = p[0][1]
        for pr in p[1:]:
            if last == pr[0]:
                last = pr[1]
            else:
                res.append((start,last))
                start = pr[0]
                last = pr[1]
        res.append((start,last))
        progs2.extend(res)
    acc = [0] * (len(times)+1)
    for p in progs2:
        acc[rev_times[p[0]]]+=1
        acc[rev_times[p[1]]+1]-=1
    for i in range(len(acc)-1):
        acc[i+1] += acc[i]
    print(max(acc))
    # acc = [0] * len(times)
    # progs.sort(key = lambda x:x[2])



main()

Submission status: Time Limit Exceeded

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

ans = 0

stc.sort(key=lambda x:(x[2],x[1],x[0]))

time = 10**5+3

c_imos = [[0 for i in range(time)] for j in range(c)]

for i in range(n):
    c_imos[stc[i][2]-1][stc[i][0]-1] += 1
    c_imos[stc[i][2]-1][stc[i][1]] -= 1

nd_v = [[0 for i in range(time)] for j in range(c)]

for i in range(c):
    for j in range(time):
        if j == 0:
            if c_imos[i][j] == 1:
                nd_v[i][j] = 1
        else:
            nd_v[i][j] = nd_v[i][j-1] + c_imos[i][j]

for i in range(c):
    for j in range(time):
        if nd_v[i][j] >= 2:
            nd_v[i][j] = 1
ans = 1

for i in range(time-1):
    tmp = 0
    for j in range(c):
        tmp += nd_v[j][i]
    ans = max(tmp,ans)

print(ans)

exit()
    
c_num = stc[0][2]
t_num = stc[0][1]
idx = 0
print(stc)
for i in range(1,n):
    print(t_num,i)
    if stc[idx+i][2] == c_num:
        if stc[idx+i][0] == t_num:
            stc[idx+i-1][1] = stc[idx+i][1]
            t_num = stc[idx+i][1]
            del stc[idx+i]
            idx -= 1
        else:
            print(t_num,t_num,t_num)
            c_num = stc[idx+i][2]
            t_num = stc[idx+i][1]

stc.sort(key=lambda x:x[1])
print(stc)
exit()
tmp = stc[0][1]

ans = 1
ans_tmp = 1

for i in range(1,len(stc)):
    for j in range(i+1,len(stc)):
        if tmp >= stc[j][0]:
            ans_tmp += 1
        else:
            tmp = stc[j][0]
            ans = max(ans_tmp,ans)

Submission status: Time Limit Exceeded

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

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

ans = 0
for i in range(10**5):
    a = 0
    for j in range(C):
        if T[i][j] or T[i+1][j]:
            a += 1
    ans = max(ans,a)
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N):
    s,t,c = map(int,input().split())
    T[c-1][s] += 1
    T[c-1][t] -= 1
for i in range(C):
    for j in range(10**5):
        T[i][j+1] += T[i][j]

for i in range(C):
    for j in range(10**5):
        if T[i][-j-1] == 0 and T[i][-j-2] == 1:
            T[i][-j-1] = 1
ans = 0
for i in range(10**5+1):
    ans = max(ans,sum(T[j][i] for j in range(C)))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# N個のimosなので二次元でやる 0.5がうざいので*2する( (2*10^5) * C )

# なぜか2WAが取れない

# 嘘解法？

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

for i in range(C):
    for j in range(1, x):
        imos[i][j] += imos[i][j - 1]
        imos[i][j] = min(1, imos[i][j])  # test

ans = 0
for j in range(x):
    tmp = 0
    for i in range(C):
        tmp += imos[i][j]
    ans = max(ans, tmp)
# print("-----------")
# for x in imos:
#     print(x)
print(ans)

# 1 3
# 3 4 2

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, C = map(int,input().split())
cha = [[] for _ in range(C+1)]
stc = [list(map(int, input().split())) for _ in range(n)]
stc.sort()
for s, t, c in stc:
    cha[c].append([s, t])
result = np.zeros(2*10**5)
for i in range(1, C+1):
    x = np.zeros(2*10**5)
    for s, t in cha[i]:
        x[s*2-(x[s*2-1]==0)+2*(x[s*2]==1):t*2] += 1
    result += x
print(int(max(result)))

Submission status: Time Limit Exceeded

Solution code:
#それぞれの時間に注目して最大のものを考える
#いもす法？
#チャンネル同じ場合を考慮し忘れていた
#チャンネル分けてチェックすればええやん
n,c=map(int,input().split())
imos=[[0 for i in range(c)] for j in range(10**5+1)]#1~10**5+1
for i in range(n):
    s,t,_c=map(int,input().split())
    imos[s-1][_c-1]+=1
    imos[t][_c-1]-=1
for i in range(1,10**5+1):
    for j in range(c):
        imos[i][j]+=imos[i-1][j]
imosans=[0]*(10**5+1)
for i in range(10**5+1):
    for j in range(c):
        imosans[i]+=(imos[i][j]>=1)
print(max(imosans))

Submission status: Time Limit Exceeded

Solution code:
n,c = map(int,input().split())
L = [[] for i in range(c)]
for i in range(n):
    s,t,k = map(int,input().split())
    L[k-1].append([s,t])
for i in range(c):
    L[i].sort()
for i in range(c):
    d = [0]*(10**5+1)
    T = []
    for j in range(len(L[i])):
        d[L[i][j][0]] += 1
        d[L[i][j][1]] -= 1
    for j in range(10**5):
        d[j+1] += d[j]
    cur = 0
    start = 0
    end = 0
    for j in range(10**5+1):
        if d[j] == 1 and cur == 0:
            start = j
            cur = 1
        elif d[j] == 0 and cur == 1:
            end = j
            cur = 0
            T.append([start*2-1, end*2])
    L[i] = T
dp = [0]*((10**5)*2+3)
ans = 0
for i in range(c):
    for j in range(len(L[i])):
        dp[L[i][j][0]] += 1
        dp[L[i][j][1]] -= 1
for j in range(1,(10**5)*2+3):
    dp[j] = dp[j-1]+dp[j]
    ans = max(ans, dp[j])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, C, *L = map(int, open(0).read().split())
program = np.zeros((10**5+2,31),np.int32)
for s,t,c in zip(*[iter(L)]*3):
  program[s][c] += 1
  program[t+1][c] += -1
program = np.cumsum(program, axis=0)
ans = np.apply_along_axis(np.count_nonzero, 1, program).max()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from collections import Counter

n, c = map(int, input().split())
time_np = np.empty(0)
for i in range(n):
    s, t, c = map(int, input().split())
    _a = np.arange(s-0.5, t, 0.5)
    time_np = np.append(time_np, _a)
mycounter = Counter(list(time_np))
print(mycounter.most_common()[0][1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from collections import Counter

n, c = map(int, input().split())
s_list = []
t_list = []
c_list = []
time_np = np.empty(0)

for i in range(n):
    s, t, c = map(int, input().split())
    _a = np.arange(s-0.5, t, 0.5)
    time_np = np.append(time_np, _a)
    c_list.append(c)

mycounter = Counter(list(time_np))
print(mycounter.most_common()[0][1])

Submission status: Time Limit Exceeded

Solution code:
N, C = map(int, input().split())
dic = []
L = 0
for i in range(N):
  s, t, c = map(int, input().split())
  dic += [(c-1,s,t)]
  if 2*t+1>L:
    L = 2*t+1

sm = [0]*L
for c in range(C):
  tt = [0]*(L)
  for i in range(N):
    if dic[i][0]==c:
      tt[dic[i][1]*2-1] += 1
      tt[dic[i][2]*2] -= 1
  for i in range(1,L):
    tt[i] += tt[i-1]
  for i in range(L):
    if tt[i]>0:
      sm[i] += 1
print(max(sm))

Submission status: Time Limit Exceeded

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

L = 2*100000+1
sm = [0]*L
for c in range(C):
  tt = [0]*(L)
  for i in range(N):
    if dic[i][0]==c:
      tt[dic[i][1]*2-1] += 1
      tt[dic[i][2]*2] -= 1
  for i in range(1,L):
    tt[i] += tt[i-1]
  for i in range(L):
    if tt[i]>0:
      sm[i] += 1
print(max(sm))