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: Time Limit Exceeded

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

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]


count = [0 for i in range(max_end)]
tv_times = []
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        time.remove(remove_list[i])
        time.remove(remove_list[i])

    for i in range(len(time)//2):
        # print(time,remove_list)
        for j in range(max(time[2*i]-1,0),time[2*i+1]):
            count[j] += 1

print(max(count))

Submission status: Time Limit Exceeded

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

channells = {}
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    if c in channells.keys():
        channells[c] += [s,g]
    else:
        channells[c] = [s,g]

count = [0 for i in range(max_end)]
tv_times = []
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        time.remove(remove_list[i])
        time.remove(remove_list[i])

    for i in range(len(time)//2):
        # print(time,remove_list)
        for j in range(max(time[2*i]-1,0),time[2*i+1]):
            count[j] += 1

print(max(count))

Submission status: Time Limit Exceeded

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

channells = {}
for i in range(N):
    s,g,c = tv_times[i]
    if c in channells.keys():
        channells[c] += [s,g]
    else:
        channells[c] = [s,g]

tv_times = []
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for j in range(len(remove_list)):
        time.remove(remove_list[j])
        time.remove(remove_list[j])

    for i in range(len(time)//2):
        tv_times.append([time[2*i],time[2*i+1]])

max_end = -1
for i in range(len(tv_times)):
    max_end = max(tv_times[i][1],max_end)

count = [0 for i in range(max_end)]
for ni in range(len(tv_times)):
    for time in range(max(tv_times[ni][0]-1,0),tv_times[ni][1]):
        count[time] += 1

print(max(count))

Submission status: Time Limit Exceeded

Solution code:
# encoding][utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]
# print(tv_times)

channells = {}
for i in range(N):
    s,g,c = tv_times[i]
    if c in channells.keys():
        channells[c] += [s,g]
    else:
        channells[c] = [s,g]

tv_times = []
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for j in range(len(remove_list)):
        time.remove(remove_list[j])
        time.remove(remove_list[j])

    for i in range(len(time)//2):
        tv_times.append([time[2*i],time[2*i+1]])


# print(channells)


max_end = -1
# print(tv_times)
for i in range(len(tv_times)):
    max_end = max(tv_times[i][1],max_end)

# print(tv_times)
# print(max_end)
count = [0 for i in range(max_end)]
for ni in range(len(tv_times)):
    for time in range(max(tv_times[ni][0]-1,0),tv_times[ni][1]):
        count[time] += 1

# print(count)
print(max(count))

Submission status: Time Limit Exceeded

Solution code:
# encoding][utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]
# print(tv_times)

channells = {}
for i in range(N):
    if tv_times[i][2] in channells.keys():
        channells[tv_times[i][2]] += [tv_times[i][0],tv_times[i][1]]
    else:
        channells[tv_times[i][2]] = [tv_times[i][0],tv_times[i][1]]

tv_times = []
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for j in range(len(remove_list)):
        time.remove(remove_list[j])
        time.remove(remove_list[j])

    for i in range(len(time)//2):
        tv_times.append([time[2*i],time[2*i+1]])


# print(channells)


max_end = -1
# print(tv_times)
for i in range(len(tv_times)):
    max_end = max(tv_times[i][1],max_end)

# print(tv_times)
# print(max_end)
count = [0 for i in range(max_end)]
for ni in range(len(tv_times)):
    for time in range(max(tv_times[ni][0]-1,0),tv_times[ni][1]):
        count[time] += 1

# print(count)
print(max(count))

Submission status: Time Limit Exceeded

Solution code:
# encoding,utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import numpy as np

N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]
# print(tv_times)
tv_times = np.array(tv_times)

tv_times = np.sort(tv_times,axis=0)

for i in range(N):
    for j in range(i,N):
        if tv_times[i,2] == tv_times[j,2]:
            if tv_times[i,0] == tv_times[j,1] or tv_times[i,1]==tv_times[j,0]:
                tv_times[i,0] = min(tv_times[i,0],tv_times[j,0])
                tv_times[i,1] = max(tv_times[i,1],tv_times[j,1])
                tv_times[j,0] = 0
                tv_times[j,1] = 0

max_end = -1
# print(tv_times)
for i in range(N):
    max_end = max(tv_times[i,1],max_end)

# print(tv_times)
# print(max_end)
count = [0 for i in range(max_end)]
for ni in range(N):
    for time in range(max(tv_times[ni,0]-1,0),tv_times[ni,1]):
        count[time] += 1

# print(count)
print(max(count))

Submission status: Time Limit Exceeded

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]
# print(tv_times)
for i in range(N):
    for j in range(i,N):
        if tv_times[i][2] == tv_times[j][2]:
            if tv_times[i][0] == tv_times[j][1] or tv_times[i][1]==tv_times[j][0]:
                tv_times[i][0] = min(tv_times[i][0],tv_times[j][0])
                tv_times[i][1] = max(tv_times[i][1],tv_times[j][1])
                tv_times[j][0] = 0
                tv_times[j][1] = 0

max_end = -1
# print(tv_times)
for i in range(N):
    max_end = max(tv_times[i][1],max_end)

# print(max_end)
count = [0 for i in range(max_end)]
for ni in range(N):
    for time in range(max(tv_times[ni][0]-1,0),tv_times[ni][1]):
        count[time] += 1

# print(count)
print(max(count))


"""
[S-1~T]

Q1
3 2
1 7 2
7 8 1
8 12 1


つまり
0.5~7
6.5~8
7.5~12
"""

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,C=map(int,input().split())
 
def get_unique_list(seq):
  seen = []
  return [x for x in seq if x not in seen and not seen.append(x)]
 
Record=np.empty((0,3), int)
 
for i in range(N):
  lis=list(map(int,input().split()))
  n=np.array(lis)
  Record=np.append(Record,[n],axis=0)
#print(Record)
 
 
newRecord=np.empty((0,3), int)
for c in range(C):
  Recordi=np.empty((0,3), int)
  for i in range(N):
    if Record[i][2]==c+1:
      Recordi=np.append(Recordi,[Record[i]],axis=0)
  
  sort_Recordi=Recordi[np.argsort(Recordi[:,0])]
  #print(sort_Recordi)
  for j in range(len(sort_Recordi)-1):
    if sort_Recordi[j][1]==sort_Recordi[j+1][0]:
      sort_Recordi[j][1]=sort_Recordi[j+1][1]
      sort_Recordi[j+1][0]=sort_Recordi[j][0]
  sort_Recordi_u=set(map(tuple,sort_Recordi))
  sort_Recordi_u=np.array(list(sort_Recordi_u))
  #print(sort_Recordi_u)
  for k in range(len(sort_Recordi_u)):
    newRecord=np.append(newRecord,[sort_Recordi_u[k]],axis=0)
    
      
#print(newRecord)
nofc=np.zeros(10**5+1,dtype=int)
 
for a in newRecord:
  vec=np.ones(a[1]-a[0]+1,dtype=int)
  nofc[a[0]:a[1]+1]+=vec
#print(vec)
#print(nofc[:13])
print(int(max(nofc)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,C=map(int,input().split())
 
def get_unique_list(seq):
  seen = []
  return [x for x in seq if x not in seen and not seen.append(x)]

Record=np.empty((0,3), int)
 
for i in range(N):
  lis=list(map(int,input().split()))
  n=np.array(lis)
  Record=np.append(Record,[n],axis=0)
#print(Record)


newRecord=np.empty((0,3), int)
for c in range(C):
  Recordi=np.empty((0,3), int)
  for i in range(N):
    if Record[i][2]==c+1:
      Recordi=np.append(Recordi,[Record[i]],axis=0)
  
  sort_Recordi=Recordi[np.argsort(Recordi[:,0])]
  #print(sort_Recordi)
  for j in range(len(sort_Recordi)-1):
    if sort_Recordi[j][1]==sort_Recordi[j+1][0]:
      sort_Recordi[j][1]=sort_Recordi[j+1][1]
      sort_Recordi[j+1][0]=sort_Recordi[j][0]
  sort_Recordi_u=set(map(tuple,sort_Recordi))
  sort_Recordi_u=np.array(list(sort_Recordi_u))
  #print(sort_Recordi_u)
  for k in range(len(sort_Recordi_u)):
    newRecord=np.append(newRecord,[sort_Recordi_u[k]],axis=0)
    
      
#print(newRecord)
nofc=np.zeros(10**5+1)
 
for a in newRecord:
  vec=np.ones(a[1]-a[0]+1)
  nofc[a[0]:a[1]+1]+=vec
#print(vec)
#print(nofc[:13])
print(int(max(nofc)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,C=map(int,input().split())

def get_unique_list(seq):
  seen = []
  return [x for x in seq if x not in seen and not seen.append(x)]
  


Record=[]

for i in range(N):
  Record.append(list(map(int,input().split())))

newRecord=[]
for c in range(C):
  Recordi=[]
  for i in range(N):
    if Record[i][2]==c+1:
      Recordi.append(Record[i])
  sort_Recordi=sorted(Recordi,key = lambda x:x[0])
  for j in range(len(sort_Recordi)-1):
    if sort_Recordi[j][1]==sort_Recordi[j+1][0]:
      sort_Recordi[j][1]=sort_Recordi[j+1][1]
      sort_Recordi[j+1][0]=sort_Recordi[j][0]
  sort_Recordi_u=get_unique_list(sort_Recordi)
  #print(sort_Recordi_u)
  for k in range(len(sort_Recordi_u)):
    newRecord.append(sort_Recordi_u[k])
    
      
#print(newRecord)
nofc=np.zeros(10**5+1)

for a in newRecord:
  vec=np.ones(a[1]-a[0]+1)
  nofc[a[0]:a[1]+1]+=vec
#print(vec)
#print(nofc[:13])
print(int(max(nofc)))

Submission status: Time Limit Exceeded

Solution code:
from collections import*
n,c=map(int,input().split())
d=defaultdict(list)
for s,t,r in sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[0]):
    if len(d[r])>0:
        if d[r][-1][-1]==s:
            d[r].append((d[r].pop()[0],t))
        else:
            d[r].append((s,t))
    else:
        d[r].append((s,t))
di=[]
for i in d.values():
    di+=i
x=sorted(di,key=lambda x:x[0])
ans=0
bannpei=0
#print(x)
while len(x)>0:
    for s,t in x.copy():
        if bannpei+1<=s:
            x.remove((s,t))
            bannpei=t
#        print(bannpei)
    ans+=1
    bannpei=0
#    print(x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import*
n,c=map(int,input().split())
d=defaultdict(list)
for s,t,r in sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[0]):
    if len(d[r])>0:
        if d[r][-1][-1]==s:
            d[r].append((d[r].pop()[0],t))
        else:
            d[r].append((s,t))
    else:
        d[r].append((s,t))
di=[]
for i in d.values():
    di+=i
x=sorted(di,key=lambda x:x[0])
ans=0
bannpei=0
#print(x)
while len(x)>0:
    for s,t in x.copy():
        if bannpei+1<=s:
            x.remove((s,t))
            bannpei=t
#        print(bannpei)
    ans+=1
    bannpei=0
#    print(x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy
N,C=map(int,input().split())
S=[numpy.array([0 for j in range(10**5)]) for i in range(C)]

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

ans=numpy.array([0 for j in range(10**5)])
for i in range(C):
    ans=ans+S[i]
print(max(ans))

Submission status: Time Limit Exceeded

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

times = [0] * 2 * (10 ** 5 + 1)
channel = [[0] * 2 * (10 ** 5 + 1) for _ in range(C)]
for i in range(N):
    s, t, c = items[i]
    c -= 1
    channel[c][2 * s - 1] += 1
    channel[c][2 * t] -= 1

for c in range(C):
    for i in range(len(times) - 1):
        channel[c][i + 1] += channel[c][i]
        if channel[c][i + 1] >= 1:
            times[i + 1] += 1

print(max(times))

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] = dic[c][i][0]
                dic[c].pop(i)
                l -= 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1

    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
dic = [[] for _ in range(C + 1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    dic[c].append([s, t])
for c in range(C + 1):
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(100002)]
for c in range(C + 1):
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

ans = 0
for i in range(1, 100001):
    f[i] += f[i - 1]
    if ans < f[i]:
        ans = f[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, C = map(int, input().split())
dic = [[] for _ in range(C + 1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    dic[c].append([s, t])
for c in range(C + 1):
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(100002)]
for c in range(C + 1):
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

ans = 0
for i in range(1, 100001):
    f[i] += f[i - 1]
    if ans < f[i]:
        ans = f[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
N, C = map(int, input().split())
dic = defaultdict(list)
for _ in range(N):
    s, t, c = input().split()
    dic[c].append([int(s), int(t)])
for c in dic:
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(10 ** 5 + 2)]
for c in dic:
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

ans = 0
for i in range(1, 10 ** 5 + 1):
    f[i] += f[i - 1]
    if ans < f[i]:
        ans = f[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, C = input().split()
N = int(N)
C = int(C)
    
stcList = []
for i in range(N):
    s, t, c = input().split()
    s = int(s)
    t = int(t)
    c = int(c)
    stcList.append((s,t,c))
    
stcList.sort(key=lambda x:x[2])
stcl = []
ccache = []
cc = 0
for stc in stcList:
    isDuplicate = False
    if stc[2] == cc:
        for ca in ccache:
            if stc[0] == ca[1]:
                ca[1] = stc[1]
                isDuplicate = True
                break
            elif stc[1] == ca[0]:
                ca[0] = stc[0]
                isDuplicate = True
                break
        if not isDuplicate:
            ccache.append(list(stc))
    else:
        stcl.extend(ccache)
        ccache = []
        ccache.append(list(stc))
    cc = stc[2]
stcl.extend(ccache)

stcl.sort(reverse = True, key=lambda x:x[1])
countlist = [0] * (stcl[0][1]+1)
count = 0
for st in stcl:
    countlist[st[0]-1] += 1
    countlist[st[1]] -= 1
for i,c in enumerate(countlist):
    if i > 0:
        countlist[i] += countlist[i-1]
print(max(countlist))

Submission status: Time Limit Exceeded

Solution code:
N, C = input().split()
N = int(N)
C = int(C)
    
stcList = []
for i in range(N):
    s, t, c = input().split()
    s = int(s)
    t = int(t)
    c = int(c)
    stcList.append((s,t,c))
    
stcList.sort(key=lambda x:x[2])
stcl = []
cc = 0
for stc in stcList:
    isDuplicate = False
    if stc[2] == cc:
        for ca in stcl:
            if stc[0] == ca[1]:
                ca[1] = stc[1]
                isDuplicate = True
                break
            elif stc[1] == ca[0]:
                ca[0] = stc[0]
                isDuplicate = True
                break
        if not isDuplicate:
            stcl.append(list(stc))
    else:
        stcl.append(list(stc))
    cc = stc[2]

stcl.sort(reverse = True, key=lambda x:x[1])
countlist = [0] * (stcl[0][1]+1)
count = 0
for st in stcl:
    countlist[st[0]-1] += 1
    countlist[st[1]] -= 1
for i,c in enumerate(countlist):
    if i > 0:
        countlist[i] += countlist[i-1]
print(max(countlist))

Submission status: Time Limit Exceeded

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

stcList = []
for i in range(N):
    s, t, c = input().split()
    s = int(s)
    t = int(t)
    c = int(c)
    stcList.append((s,t,c))

stcl = []
for cc in range(C+1):
    cache = []
    for stc in stcList:
        isDuplicate = False
        if stc[2] == cc:
            for ca in cache:
                if stc[0] == ca[1]:
                    ca[1] = stc[1]
                    isDuplicate = True
                    break
                elif stc[1] == ca[0]:
                    ca[0] = stc[0]
                    isDuplicate = True
                    break
            if not isDuplicate:
                cache.append(list(stc))
    stcl.extend(cache)

count = 0
for st in stcl:
    stcache = 0
    edcache = 0
    for stc in stcl:
        if stc[0] <= st[0] and st[0] <= stc[1]:
            stcache += 1
        if stc[0] <= st[1] and st[1] <= stc[1]:
            edcache += 1
    if count < max(stcache, edcache):
        count = max(stcache, edcache)

print(count)

Submission status: Time Limit Exceeded

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

stcList = []
for i in range(N):
    s, t, c = input().split()
    s = int(s)
    t = int(t)
    c = int(c)
    stcList.append((s,t,c))

stcl = []
for cc in range(C+1):
    cache = []
    for stc in stcList:
        isDuplicate = False
        if stc[2] == cc:
            for ca in cache:
                if stc[0] == ca[1]:
                    ca[1] = stc[1]
                    isDuplicate = True
                    break
                elif stc[1] == ca[0]:
                    ca[0] = stc[0]
                    isDuplicate = True
                    break
            if not isDuplicate:
                cache.append(list(stc))
    stcl.extend(cache)

mins = 10*5
maxt = 0
for x in stcl:
    if x[0] < mins:
        mins = x[0]
    if maxt < x[1]:
        maxt = x[1]

count = 0
for i in range(mins, maxt):
    cache = 0
    for stc in stcl:
        if stc[0] <= i and i <= stc[1]:
            cache += 1
    if count < cache:
        count = cache

print(count)

Submission status: Time Limit Exceeded

Solution code:
N,C = list(map(int,input().split()))
imos = [[0 for j in range(10**5+1)] for i in range(C)]
for i in range(N):
    l,r,c = list(map(int,input().split()))
    c -= 1
    l -= 1
    imos[c][l] += 1
    imos[c][r] -= 1

for c in range(C):
    for i in range(1,10**5+1):
        imos[c][i] += imos[c][i-1]
for c in range(C):
    for i in range(10**5+1):
        if (imos[c][i] > 0):
            imos[c][i] = 1

ans = 0

for i in range(10**5):
    cnt = 0
    for c in range(C):
        cnt += imos[c][i]

    ans = max(cnt,ans)

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
T = 10**5
print(max([len(list(filter(lambda x:x[0] <= i <= x[1], prog)))
           for i in range(T+1)]))

Submission status: Time Limit Exceeded

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

lenA = 200001
A = [[0]*lenA for _ in range(C)]
for i in range(N):
    a = 1

for i in range(C):
    for (s,t) in STC[i]:
        A[i][s*2-1] += 1
        A[i][t*2] -= 1

for i in range(C):
    for j in range(lenA-1):
        A[i][j+1] += A[i][j]

Ans = [0]*lenA
for i in range(C):
    for j in range(lenA):
        if A[i][j] > 0:
            Ans[j] += 1

print(max(Ans))

Submission status: Time Limit Exceeded

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *


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

s = [-1e9] * C
count = 0
index = 0
for i in range(100000):
    if index == N:
        break
    f = stc[index][0]
    while(index < N and f == i):
        if f == stc[index][0]:
            if i == stc[index][0]:
                for j in range(C):
                    if s[j] <= stc[index][0] - 0.5:
                        if s[j] == -1e9:
                            count += 1
                        s[j] = stc[index][1]
                        break
                index += 1
            if count == C:
                print(C)
                sys.exit(0)
            s = sorted(s, reverse=True)
        else:
            break
print(count)

Submission status: Time Limit Exceeded

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

N, C = map(int, input().split())
T = 10**5+2

c_ls = [[0] * T for _ in range(C)]
# いもす
for i in range(N):
    s, t, c = map(int, input().split())
    c_ls[c-1][s] += 1
    c_ls[c-1][t] -= 1
# 各チャンネル毎の累積和
for i in range(C):
    for j in range(1, T):
        c_ls[i][j] += c_ls[i][j-1]
# 他チャンネルとの重複を見るために開始を1早める
for i in range(C):
    for j in range(1, T):
        if c_ls[i][j] > c_ls[i][j-1]:
            c_ls[i][j-1] += 1
# 全チャンネルを合計
sm = [0] * T
for i in range(C):
    for j in range(T):
        sm[j] += c_ls[i][j]
# 重複が一番多くなる箇所が答え
print(max(sm))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from pprint import pprint
N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]

X = 10**5+2

c_s = [[0 for _ in range(X)] for _ in range(C)]
c_t = [[0 for _ in range(X)] for _ in range(C)]

# チャンネルごとにマッピング
for s,t,c in stc:
    c_s[c-1][s] += 1
    c_t[c-1][t] -= 1

# for c in range(C):
#     pprint(c_s[c][:14])
#     pprint(c_t[c][:14])
# print()

# チャンネルごとにいもす累計
c_rec = [[0 for _ in range(X)] for _ in range(C)]
for c in range(C):
    c_rec[c][0] = c_s[c][0] + c_t[c][0]
    for i in range(1,X):
        c_rec[c][i] = c_rec[c][i-1] + c_s[c][i] + c_t[c][i]

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# チャンネルごとのスタートを0.5分ずらす
for c in range(C):
    for i in range(X-1):
        diff = c_rec[c][i+1] - c_rec[c][i]
        if diff > 0: # 負はずらさない
            c_rec[c][i] += diff

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# 合計する
sumlist = [0 for _ in range(X)]
for c in range(C):
    for i in range(X):
        sumlist[i] += c_rec[c][i]

# pprint(sumlist[:14])

print(max(sumlist))

Submission status: Time Limit Exceeded

Solution code:
N,C=map(int,input().split())
Time=[[0]*(10**5+1)]*C
for i in range(N):
  s,t,c=map(int,input().split())
  T_c=list(Time[c-1])
  T_c[s-1:t]=[1]*(t-s+1)
  Time[c-1]=list(T_c)
Times=max(map(sum,zip(*Time)))
print(Times)

Submission status: Time Limit Exceeded

Solution code:
N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Time=[[0]*(10**5+1)]*C
Set={0}
for i in range(N):
  c=List[i][2]
  s=List[i][0]
  t=List[i][1]
  T_c=list(Time[c-1])
  T_c[s-1:t]=[1]*(t-s+1)
  Time[c-1]=list(T_c)
  Set.add(s-1)
  Set.add(t)
T=0
T_max=0
for t in Set:
  for c in range(C):
    T+=Time[c][t]
  if T_max<T:
    T_max=T
  T=0
print(T_max)

Submission status: Time Limit Exceeded

Solution code:
N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Time=[[0]*(10**5+1)]*C
for i in range(N):
  c=List[i][2]
  s=List[i][0]
  t=List[i][1]
  T_c=list(Time[c-1])
  T_c[s-1:t]=[1]*(t-s+1)
  Time[c-1]=list(T_c)
T=0
T_max=0
for t in range(10**5+1):
  for c in range(C):
    T+=Time[c][t]
  if T_max<T:
    T_max=T
  T=0
print(T_max)

Submission status: Time Limit Exceeded

Solution code:
N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Time=[[0]*(10**5+1)]*C
for i in range(N):
  T_c=list(Time[List[i][2]-1])
  T_c[List[i][0]-1:List[i][1]]=[1]*(List[i][1]-List[i][0]+1)
  Time[List[i][2]-1]=list(T_c)
T=0
T_max=0
for t in range(10**5):
  for c in range(C):
    T+=Time[c][t]
  if T_max<T:
    T_max=T
  T=0
print(T_max)

Submission status: Time Limit Exceeded

Solution code:
N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Channel=[[]]*C
for i in range(N):
  Channel_kari=list(Channel[List[i][2]-1])
  Channel_kari.append(i)
  Channel[List[i][2]-1]=list(Channel_kari)
Time=[]
for c in range(C):
  T_c=[0]*(10**5)
  for i in Channel[c]:
    T_c[List[i][0]-1:List[i][1]]=[1]*(List[i][1]-List[i][0]+1)
  Time.append(T_c)  
T=0
T_max=0
for t in range(10**5):
  for c in range(C):
    T+=Time[c][t]
  if T_max<T:
    T_max=T
  T=0
print(T_max)

Submission status: Time Limit Exceeded

Solution code:
N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Channel=[[]]*C
for i in range(N):
  Channel_kari=list(Channel[List[i][2]-1])
  Channel_kari.append(i)
  Channel[List[i][2]-1]=list(Channel_kari)
Time=[]
for c in range(C):
  T_c=[0]*(10**5)
  for i in Channel[c]:
    T_c[List[i][0]-1:List[i][1]]=[1]*(List[i][1]-List[i][0]+1)
  Time.append(T_c)  
Times_sum=[]
T=0
for t in range(10**5):
  for c in range(C):
    T+=Time[c][t]
  Times_sum.append(T)
  T=0
print(max(Times_sum))

Submission status: Time Limit Exceeded

Solution code:
n, c = map(int, input().split())
r = []
for i in range(n):#h:高さ
    r.append([int(m) for m in input().split()])

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

xli = []
p = 0
for i in range(n):
    if i == 0:
        xli.append(r[i])
    else:
        xli.sort(key=lambda x: (x[1], x[0], x[2]), reverse=True)
        for jnum, j in enumerate(xli, 0):
            if (j[1] < r[i][0]) or (j[1] <= r[i][0] and j[2] == r[i][2]):
                p = 1
                xli[jnum] = r[i]
                break
        if p == 0:
            xli.append(r[i])
        p = 0

print(len(xli))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,c = map(int, input().split())
tv = []
T = 0
for _ in range(n):
    line = list(map(int, input().split()))
    T = max(T, line[1])
    tv.append(line)

rm = [0 for _ in range(2*T)]

for ci in range(c):
    tt = [0 for _ in range(2*T)]
    for i in range(n):
        if tv[i][2]==ci+1:
            tt[2*tv[i][0]-2] += 1
            tt[2*tv[i][1]-1] -= 1
    for t in range(2*T-1):
        tt[t+1] = tt[t+1]+tt[t]
    for t in range(2*T):
        if tt[t]>0:
            rm[t] += 1
    # print(tt)
# print(rm)
ret = 0
for s in rm:
    ret = max(ret, s)
print(ret)

Submission status: Time Limit Exceeded

Solution code:
T_MAX = 10**5
n, nc = list(map(int, input().split()))
stc = [list(map(int, input().split())) for _ in range(n)]

nrecs = [0]*(2*T_MAX+1)
for c in range(1, nc+1):
    rec = [0]*(2*T_MAX+1)
    for i in range(n):
        if stc[i][2] == c:
            rec[stc[i][0]*2-1] += 1
            rec[stc[i][1]*2] -= 1
    for i in range(1, 2*T_MAX+1):
        rec[i] += rec[i-1]
    for i in range(2*T_MAX+1):
        if rec[i] > 0:
            nrecs[i] += 1
    
print(max(nrecs))

Submission status: Time Limit Exceeded

Solution code:
T_MAX = 10**5
n, nc = list(map(int, input().split()))
stc = [list(map(int, input().split())) for _ in range(n)]

recs = [[0]*(2*T_MAX+1) for i in range(nc)]
for i in range(n):
    s, t, c = stc[i]
    recs[c-1][2*s-1] += 1
    recs[c-1][2*t] -= 1

nrecs = [0]*(2*T_MAX+1)
for c in range(nc):
    for i in range(1, 2*T_MAX+1):
        recs[c][i] += recs[c][i-1]
        if recs[c][i] > 0:
            nrecs[i] += 1
    
print(max(nrecs))