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: Runtime Error

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: Runtime Error

Solution code:
n,c = map(int, input().split( ))
v = [0]*(10**5+1)
#ci不要ではなかった
#チャンネルは継続できる
#座圧不要
Cs = [set() for i in range(c+1)]
Ct = [set() for i in range(c+1)]
for i in range(n):
    si,ti,ci = map(int, input().split( ))
    if ti in Cs[ci]:
        Cs[ci].remove(ti)
    else:
        Ct[ci].add(ti)
    if si in Cs[ci]:
        Ct[ci].remove(si)
    else:
        Cs[ci].add(si)
ans = 0
tmp = 0
for i in range(c+1):
    for si in Cs[i]:
        v[si]+=1
    for ti in Ct[i]:
        
        v[ti+1]-=1
for i in range(1,10**5+1):
    tmp += v[i]
    ans = max(tmp,ans)
print(ans)

Submission status: Runtime Error

Solution code:
n,_ = map(int, input().split( ))
v = [0]*(10**5+1)
#ci不要
#座圧不要
for i in range(n):
    si,ti,ci = map(int, input().split( ))
    v[si]+=1;v[ti+1]-=1
ans = 0
tmp = 0
for i in range(1,10**5+1):
    tmp += v[i]
    ans = max(tmp,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

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

now_acc = accumulate(now)
print(max(now_acc))

Submission status: Runtime Error

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: Runtime Error

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

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

n,c = m()

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

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

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

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

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

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

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

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

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

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

print(ans)

Submission status: Runtime Error

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

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

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

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

print(ans)

Submission status: Runtime Error

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

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

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

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

    ans = max(ans, len(record))

print(len(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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]

                elif end!=lists[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

Submission status: Runtime Error

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(1,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]

                elif end!=lists[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
    else:
        pass

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: Runtime Error

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(1,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]

                elif end!=lists[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
    else:
        pass

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

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,101):
  startlists[i]+=startlists[i-1]
  endlists[i]+=endlists[i-1]


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

Submission status: Runtime Error

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])
a.sort(key=lambda x:x[2])

# 同じチャンネルの番組を繋げる。
for i in range(n-1):
    if a[i][1]==a[i+1][0] and a[i][2]==a[i+1][2]:
        a[i][1]-=1
# いもす法
x=[0]*(10**5+1)
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: Runtime Error

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+1)
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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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 t+1>L:
    L = 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: Runtime Error

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],c])
    ch[c] = [s,t]
for i in range(1,C+1):
  if ch[i] != [0,0]:
    p_true.append([*ch[i],i])
p_true.sort()

Submission status: Runtime Error

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(N):
            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: Runtime Error

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))
                # 3連続以上を考慮して左端を更新
                C[i][j][0] = l1
            else:
                LR.append((l2, r2))

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

Submission status: Runtime Error

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

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

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, t * 2, 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]

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

print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np
N,C=map(int,input().split())
X=np.array([[0]*2*10**5]*(C+1))
for i in range(N):
  s,t,c=map(int,input().split())
  s=2*s-1
  t=2*t
  for j in range(s,t+1):
    X[c][j]=1
answer=max(X.sum(axis=0))
print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np
N,C=map(int,input().split())
X=np.array([[0]*2*10**5]*(C+1))
for i in range(N):
  s,t,c=map(int,input().split())
  s=2*s-1
  t=2*t
  for j in range(s,t+1):
    X[c][j]=1
answer=max(X.sum(axis=0))
print(answer)

Submission status: Runtime Error

Solution code:
import sys
from itertools import accumulate
n, c = [int(i) for i in sys.stdin.readline().split()]
ls = [0 for i in range(10**5+1)]
for i in range(n):
    s, t, c = [int(i) for i in sys.stdin.readline().split()]
    ls[s] += 1
    ls[t+1] -= 1
ls = [i for i in accumulate(ls)]
print(max(ls))

Submission status: Runtime Error

Solution code:
import sys
import heapq  # heapqライブラリのimport

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = rl()
STC = [[] for _ in range(C+1)]

for _ in range(N):
    s, t, c = rl()
    STC[c].append((s, t))

for i in range(1, C+1):
    stc = STC[i]
    if len(stc) > 1:
        for j in range(1, len(stc)):
            if stc[j][0] == stc[j-1][1]:
                stc[j] = (stc[j-1][0], stc[j][1])
                stc.pop(j-1)
        STC[i] = stc

program = []
for stc_list in STC:
    for s, t in stc_list:
        program.append((s, t))

program.sort()

recorder = [-1]
heapq.heapify(recorder)

for s, t in program:
    if s-0.5 > recorder[0]:
        heapq.heappop(recorder)
    heapq.heappush(recorder, t)

print(len(recorder))

Submission status: Runtime Error

Solution code:
import sys
import heapq  # heapqライブラリのimport

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = rl()
STC = [[] for _ in range(C+1)]

for _ in range(N):
    s, t, c = rl()
    STC[c].append((s, t))

for i in range(1, C+1):
    stc = STC[i]
    if len(stc) > 1:
        for j in range(1, len(stc)):
            if stc[j][0] == stc[j-1][1]:
                stc[j] = (stc[j-1][0], stc[j][1])
                stc.pop(j-1)
        STC[i] = stc

program = []
for stc_list in STC:
    for s, t in stc_list:
        program.append((s, t))

program.sort()

recorder = [0]
heapq.heapify(recorder)

for s, t in program:
    if s-0.5 > recorder[0]:
        recorder.heappop(recorder)
    recorder.heappush(recorder, t)

print(len(recorder))

Submission status: Runtime Error

Solution code:
import sys
import heapq  # heapqライブラリのimport

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = rl()
STC = [[] for _ in range(C+1)]

for _ in range(N):
    s, t, c = rl()
    STC[c].append((s, t))

for i in range(1, C+1):
    stc = STC[i]
    for j in range(1, len(stc)):
        if stc[j][0] == stc[j-1][1]:
            stc[j] = (stc[j-1][0], stc[j][1])
            stc.pop(j-1)
    STC[i] = stc

program = []
for stc_list in STC:
    for s, t in stc_list:
        program.append((s, t))

program.sort()

recorder = [0]
heapq.heapify(recorder)

for s, t in program:
    if s-0.5 > recorder[0]:
        recorder.heappop(recorder)
    recorder.heappush(recorder, t)

print(len(recorder))

Submission status: Runtime Error

Solution code:
import sys
import heapq  # heapqライブラリのimport

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = rl()
STC = [[] for _ in range(C+1)]

for _ in range(N):
    s, t, c = rl()
    STC[c].append((s, t))

for i in range(1, C+1):
    stc = STC[i]
    for j in range(1, len(stc)):
        if stc[j][0] == stc[j-1][1]:
            stc[j] = (stc[j-1][0], stc[j][1])
            stc.pop(j-1)
    STC[i] = stc

program = []
for stc_list in STC:
    for s, t in stc_list:
        program.append((s, t))

program.sort()

recorder = [-1]
heapq.heapify(recorder)

for s, t in program:
    if s-0.5 > recorder[0]:
        heapq.heappop(recorder)
    heapq.heappush(recorder, t)

print(len(recorder))

Submission status: Runtime Error

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

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

ct = [0] * (10 ** 5 + 1)
for i in range(C):
    for j in range(10 ** 5 + 1):
        ct[j] += tt[i][j]

print(max(ct))

Submission status: Runtime Error

Solution code:
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,C = inputs()
stc = [inputs() for i in range(N)]
ans = [0]*(10**5+1)
for i in range(N):
    s,t,c, = stc[i]
    ans[s]+=1
    ans[t+1]-=1
ans = list(accumulate(ans))
print(max(ans))

Submission status: Runtime Error

Solution code:
N,C = map(int,input().split())
num = 100009
channel = [[0]*num for _ in range(C)]
time = [0]*num

max_num = 0
for i in range(N):
  s,t,c = map(int,input().split())
  s,t,c = 2*s-1,2*t,c-1
  if(channel[c-1][s-1] == 1): channel[c-1][s-1] = 0
  channel[c-1][s] = 1 
  channel[c-1][t] = 1
  max_num = max(max_num,t)

tmp = 0
for i in range(C):
 for j in range(max_num+9):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    time[a] += 1
    time[b+1] -= 1

ans = 0    
for i in range(max_num+9):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,C = map(int,input().split())
time = [0]*100009
channel = [[0]*100009 for _ in range(C)]
#(方針)チャンネル関係なしに
#同じチャンネルの連続だと録画開始時間に0.5秒のロスがない
# 同チャンネルで 1-7 7-8 → [0.5,8) → 録画機1つ(0.5~7.99) 
# 違うチャンネルで 1-7 7-8 → [0.5,7) 0.5~6.99 , [6.5,8) 6.5~7.99 → 録画機2つ

#前処理:　同チャンネルの区間をつなげる(ex. 1-7 7-8 → 1-8）
max_num = 0
for i in range(N):
 s,t,c = map(int,input().split())
 if(channel[c-1][s-1] == 1): channel[c-1][s-1] = 0
 else: channel[c-1][s-1] = 1
 channel[c-1][t-1] = 1
 max_num = max(max_num,t)

#imos法
A = []
tmp = 0
for i in range(C):
 for j in range(max_num):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    a,b = a*2,b*2
    time[a] += 1
    time[b+1] -= 1

ans = 0
for i in range(max_num+1):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)
#print(time)

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 10 ** 9 + 7


n, c = LI()
L = [0] * (10 ** 5 + 1)
for s, t, c in LIR(n):
    L[s] += 1
    L[t + 1] -= 1



print(max(accumulate(L)))

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 10 ** 9 + 7


n, c = LI()
L = [0] * 10 ** 5
for s, t, c in LIR(n):
    L[s] += 1
    L[t + 1] -= 1



print(max(accumulate(L)))

Submission status: Runtime Error

Solution code:
N,C = map(int,input().split())
ST = []
STC = [[] for _ in range(C)]
for _ in range(N):
  s,t,c = map(int,input().split())
  STC[c-1].append([s,t])
for i in range(C):
  STC[i].sort(key=lambda x:x[0])
  s=STC[i][0][0]
  t=STC[i][0][1]
  for j in range(1,len(STC[i])):
    if t==STC[i][j][0]:
      t=STC[i][j][1]
      if j==len(STC[i])-1:
        ST.append([s,0])
        ST.append([t,1])
    else:
      ST.append([s,0])
      ST.append([t,1])
ST.sort(key=lambda x:x[1])
ST.sort(key=lambda x:x[0])

ans =[0]
for st in ST:
  if st[1]==0:
    ans.append(ans[-1]+1)
  else:
    ans.append(ans[-1]-1)
print(max(ans))

Submission status: Runtime Error

Solution code:
n,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L=[[0 for i in range(10**5)] for i in range(c)]
for i in range(n):
  for j in range(l[i][0],l[i][1]+1):
    L[l[i][2]-1][j]=1
ans=[]
for i in range(10**5):
  ct=0
  for j in range(c):
    ct+=L[j][i]
    ans.append(ct)
print(max(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

n,c = map(int,input().split())

table = np.zeros(10**5+1, dtype=np.int)
ch = [[] for _ in range(c+1)]

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

times = []
for arr in ch:
    if not arr: continue
    for i in range(len(arr)):
        if i == 0: continue
        if arr[i-1][1] == arr[i][0]:
            arr[i] = [arr[i-1][0], arr[i][1]]
            arr[i-1] = []
    for ele in arr:
        if not ele: continue
        times.append(ele)

# いもす法
for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

# 累積和の最大値
ans = table.cumsum().max()

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n,c = map(int,input().split())

table = np.zeros(10**5+1, dtype=np.int)
chan = [[] for _ in range(c+2)]

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

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for s,t in times:
    table[s] += 1
    table[t+1] -= 1

# 累積和の計算
ans = table.cumsum().max()

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n,c = map(int,input().split())

table = np.zeros(10**5+1)
chan = [[] for _ in range(c+2)]

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

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for s,t in times:
    table[s] += 1
    table[t+1] -= 1

# 累積和の計算
ans = int(table.cumsum().max())

print(ans)

Submission status: Runtime Error

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

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

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

# 累積和の計算
ans = 0
for i in range(len(table)):
    if i==0 : continue
    table[i] += table[i-1]
    ans = max(ans, table[i])

print(ans)

Submission status: Runtime Error

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

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

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

# 累積和の計算
for i in range(len(table)):
    if i==1 : continue
    table[i] += table[i-1]

print(max(table))

Submission status: Runtime Error

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

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

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

# 累積和の計算
for i in range(len(table)):
    if i==1 : continue
    table[i] += table[i-1]

print(max(table))

Submission status: Runtime Error

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

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

times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

for i in range(len(table)):
    if i==1 : continue
    table[i] += table[i-1]



print(times)
print(max(table))