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 heapq
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N, C = LI()
S = [0]*N; T = [0]*N; c = [0]*N;
#s = t = c =0
maxt=int(0)
for i in range(N):
    s, t, a = LI()
    S[i],T[i] = s, t
    c[i] = a
    if maxt<t:
        maxt = t

ans = int(0)

time = [0]*(maxt+2)
timeC = [[] for _ in range(maxt+2)]
for i in range(N):
    ##########同じチャンネル
    timeC[T[i]].append(c[i])
    if not c[i] in timeC[S[i]]:
        time[S[i]] += 1
        time[T[i] + 1] -= 1
    else:
        time[S[i]+1] += 1
        time[T[i] + 1] -= 1

ansC = int(0)
for i in range(maxt+1):
    ansC += time[i]
    ans = max(ansC,ans)
#print(time)
print(ans)

Submission status: Wrong Answer

Solution code:
import heapq
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N, C = LI()
S = [0]*N; T = [0]*N; C = [0]*N;
s = t = c =0
maxt=int(0)
for i in range(N):
    s, t, c = LI()
    S[i],T[i] = s, t
    C[i] = c
    if maxt<t:
        maxt = t
ans = int(0)

time = [0]*(maxt+2)

for i in range(N):
    time[S[i]] +=1
    time[T[i]+1] -=1
ansC = int(0)
for i in range(maxt+1):
    ansC += time[i]
    ans = max(ansC,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(N)]
t = [[0] * (10 ** 5 + 1) for _ in range(C + 1)]
for i in range(N):
  for j in range(c[i][0], c[i][1]):
    t[c[i][2]][j] = 1
res = 0
for i in range(10 ** 5 + 1):
  p = 0
  for j in range(C + 1):
    p += t[j][i]
  res = max(p, res)
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(N)]
c.sort(key = lambda x: (x[1], x[0]))
#print(c)
res = C
ss = set()
for ch in range(1, C + 1):
  #print(ss)
  b = 0
  bch = 0
  t = 0
  for i in range(N):
    if i in ss:
      continue
    if c[i][2] == bch:
      if c[i][0] >= b:
        b = c[i][1]
        t += 1
        bch = c[i][2]
        ss.add(i)
    else:
      if c[i][0] > b:
        b = c[i][1]
        t += 1
        bch = c[i][2]
        ss.add(i)
    #print(b)
  if t == 0:
    res = ch - 1
    break
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(N)]
c.sort(key = lambda x: (x[1], x[0]))
#print(c)
lis = [(-1, -1, -1) for _ in range(N)]
ss = set()
def check(p, q):
  if p == (-1, -1, -1) or q == (-1, -1, -1):
    return True
  if p[1] > q[1]:
    p, q = q, p
  if p[2] == q[2] or p[2] in ss:
    if p[1] > q[0]:
      return False
  else:
    if p[1] >= q[0]:
      return False
  return True
for i in range(N - 1, -1, -1):
  p = c[i]
  l, r = 0, N - 1
  m = (l + r) // 2
  counter = 0
  now = 0
  while counter < 25:
    counter += 1
    m = (l + r) // 2
    if check(p, lis[m]):
      r = m
    else:
      l = m
  if check(p, lis[m]) == False:
    m += 1
  if m > now:
    now = m
  ss.add(p[2])
  lis[m] = p
  #print(lis, ss)
res = 0
for i in range(N):
  if lis[i] == (-1, -1, -1):
    break
  res += 1
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(N)]
c.sort(key = lambda x: (x[1], x[0]))
#print(c)
lis = [(-1, -1, -1) for _ in range(N)]
def check(p, q):
  if p == (-1, -1, -1) or q == (-1, -1, -1):
    return True
  if p[1] > q[1]:
    p, q = q, p
  if p[2] == q[2]:
    if p[1] > q[0]:
      return False
  else:
    if p[1] >= q[0]:
      return False
  return True

for i in range(N - 1, -1, -1):
  p = c[i]
  l, r = 0, N - 1
  m = (l + r) // 2
  counter = 0
  while counter < 25:
    counter += 1
    m = (l + r) // 2
    if check(p, lis[m]):
      r = m
    else:
      l = m
  if check(p, lis[m]) == False:
    m += 1
  lis[m] = p
#print(lis)
res = 0
for i in range(N):
  if lis[i] == (-1, -1, -1):
    break
  res += 1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC080D - Recording
from itertools import accumulate as acc


def main():
    N, C, *STC = map(int, open(0).read().split())
    recorders = [[0] * (2 * 10 ** 5 + 1) for _ in range(C + 1)]
    for s, t, c in zip(*[iter(STC)] * 3):
        recorders[c][2 * s - 1] += 1
        recorders[c][2 * t] -= 1
    recorders = [tuple(acc(r)) for r in recorders]
    ans = 0
    for each_half_minute in zip(*recorders):
        ans = max(ans, sum(each_half_minute))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC080D - Recording
from itertools import accumulate as acc


def main():
    N, C, *STC = map(int, open(0).read().split())
    recorders = [[0] * (2 * 10 ** 5 + 2) for _ in range(C + 1)]
    for s, t, c in zip(*[iter(STC)] * 3):
        recorders[c][2 * s - 1] += 1
        recorders[c][2 * t + 1] -= 1
    recorders = [tuple(acc(r)) for r in recorders]
    ans = 0
    for each_half_minute in zip(*recorders):
        ans = max(ans, sum(each_half_minute))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

LIM = int(10e5)
time = [0] * (LIM + 1)
N, C = list(map(int, input().split(" ")))
schs = []
for _ in range(N):
    s, t, c = list(map(int, input().split(" ")))
    schs.append((s,t,c))
schs.sort(key = lambda x:x[2])
schs.sort(key = lambda x:x[0])

# print(schs)
for i,temp in enumerate(schs):
    s,t,c = temp

    s_p,t_p,c_p = schs[i-1]
    if i != 0 and c_p == c and t_p == s:
        time[t_p + 1] += 1
        time[t + 1] -= 1

    else:
        time[s] += 1
        time[t + 1] -= 1
# print(time[:100])
ruiseki = np.cumsum(time)

# print(ruiseki[:10])
print(np.max(ruiseki[1:]))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
time = [0]*(10**5+10)
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+9):
  time[i+1] += time[i]
print(max(time))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import 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)]
stc = sorted(stc,key=lambda x:x[2])
ans = [0]*(10**5+2)
for i in range(N):
    s,t,c, = stc[i]
    if i>0 and c==stc[i-1][2] and s==stc[i-1][1]:
      ans[s+1]+=1
      ans[t+1]-=1
      continue
    ans[s]+=1
    ans[t+1]-=1
ans = list(accumulate(ans))
print(max(ans))

Submission status: Wrong Answer

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+2)
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: Wrong Answer

Solution code:
import bisect

N,C = map(int,input().split())
STC = [list(map(int,input().split())) for _ in range(N)]
STC.sort(key=lambda x:x[1])
#print(STC)

P = {}
for p in STC:
  if p[2] not in P:
    P[p[2]] = [p[:2]]
  else:
    pe = P[p[2]][-1]
    if pe[1] == p[0]:
      P[p[2]][-1][1] = p[1]
    else:
      P[p[2]].append(p[:2])
#print(P)

P2 = []
for val in P.values():
  for v in val:
    P2.append(v)
P2.sort(key=lambda x:(x[1],x[0]))
#print(P2)

P3 = []
for p in P2:
  Ptmp = [x[1] for x in P3]
  idx = bisect.bisect_right(Ptmp,p[0])
  if idx == 0:
    P3.append(p)
  else:
    if P3[idx-1][1] < p[0]:
      P3[idx-1] = p
    else:
      P3.append(p)
  P3.sort(key=lambda x:(x[1],x[0]))
#print(P3)
print(len(P3))

Submission status: Wrong Answer

Solution code:
import bisect

N,C = map(int,input().split())
STC = [list(map(int,input().split())) for _ in range(N)]
#print(STC)

P = {}
for p in STC:
  if p[2] not in P:
    P[p[2]] = [p[:2]]
  else:
    pe = P[p[2]][-1]
    if pe[1] == p[0]:
      P[p[2]][-1][1] = p[1]
    else:
      P[p[2]].append(p[:2])
#print(P)

P2 = []
for val in P.values():
  for v in val:
    P2.append(v)
P2.sort(key=lambda x:(x[1],x[0]))
#print(P2)

P3 = []
for p in P2:
  Ptmp = [x[1] for x in P3]
  idx = bisect.bisect_right(Ptmp,p[0])
  if idx == 0:
    P3.append(p)
  else:
    if P3[idx-1][1] < p[0]:
      P3[idx-1] = p
    else:
      P3.append(p)
  P3.sort(key=lambda x:(x[1],x[0]))
#print(P3)
print(len(P3))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
num = 100009*2
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][s-1] == 1): channel[c][s-1] = 0
  channel[c][s] = 1 
  channel[c][t] = 1
  max_num = max(max_num,t)

tmp = 0
for i in range(C):
 for j in range(max_num+15):
  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+15):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
num = 100009*2
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: Wrong Answer

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

N,C = map(int,input().split())
time = [0]*(100009*2)
channel = [[0]*(100009*2) 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): channel[c-1][s] = 0
 else: channel[c-1][s] = 1
 channel[c-1][t] = 1
 max_num = max(max_num,t)

#imos法
#0.5が扱いずらいので,sを2s-1,tを2tに対応させる
#ex: 1-3 → 0.5-3 → 1-6
#ex: 3-5 → 2.5-5 → 5-10
#ex: 1-3,3-5 → 1-6,5-10 → 2個必要
A = []
tmp = 0
for i in range(C):
 for j in range(max_num+10):
  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 = 2*a-1,2*b
    A.append([a,b])
    time[a] += 1
    time[b+1] -= 1
#print(A)
    
ans = 0
for i in range(max_num+10):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)
#print(time)

Submission status: Wrong Answer

Solution code:
import bisect
N,C = map(int,input().split())
G = {c:[] for c in range(1,C+1)}
T = []
for i in range(N):
    s,t,c = map(int,input().split())
    G[c] += [s,t]
    T += [s,t]
T = sorted(T)
cmax = 0
for t in range(1,T[-1]+1):
    cnt = 0
    tmp = 0
    for c in range(1,C+1):
        if len(G[c])>0:
            ind = bisect.bisect_right(G[c],t)
            if ind%2==0:
                if ind>0 and t==G[c][ind-1]:
                    cnt += 1
            else:
                cnt += 1
                if ind>2 and t==G[c][ind-1] and t==G[c][ind-2]:
                    cnt += 1
    cmax = max(cmax,cnt)
print(cmax)

Submission status: Wrong Answer

Solution code:
import bisect
N,C = map(int,input().split())
G = {c:[] for c in range(1,C+1)}
T = []
for i in range(N):
    s,t,c = map(int,input().split())
    G[c] += [s,t]
    T += [s,t]
T = sorted(list(set(T)))
cmax = 0
for t in T:
    cnt = 0
    tmp = 0
    for c in range(1,C+1):
        if len(G[c])>0:
            ind = bisect.bisect_right(G[c],t)
            if ind%2==0:
                if t==G[c][ind-1]:
                    cnt += 1
            else:
                cnt += 1
                if ind>2 and t==G[c][ind-1] and t==G[c][ind-2]:
                    cnt += 1
    cmax = max(cmax,cnt)
print(cmax)

Submission status: Wrong Answer

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

N,C = map(int,input().split())
time = [0]*(100009*2)
channel = [[0]*(100009*2) 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: Wrong Answer

Solution code:
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
    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: Wrong Answer

Solution code:
N,C = map(int,input().split())
time = [0]*100009

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


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

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
time = [0]*100009

#(方針)区間累積和(imos法)
max_t = 0
for i in range(N):
 s,t,c = map(int,input().split())
 s,t = s-1,t-1
 time[s] += 1
 time[t+1] -= 1
 max_t = max(max_t,t+1)

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

Submission status: Wrong Answer

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 + 2)
for s, t, c in LIR(n):
    L[s] += 1
    L[t + 1] -= 1



print(max(accumulate(L)))

Submission status: Wrong Answer

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

for i in range(n):
    time[program[i][0]-1] += 1
    time[program[i][1]] -= 1

count = 0
max_count = 0

for i in range(10**5+1):
    count += time[i]
    max_count = max(max_count,count)

print(max_count)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
s=[set()for _ in range(c)]
t=[0]*(200007)
for i in range(n):
	a,b,c=map(int,input().split())
	if a in s[c-1]:a+=1
	s[c-1].add(b)
	a*=2
	b*=2
	t[a-1]+=1
	t[b+1]-=1
for i in range(1,200007):t[i]+=t[i-1]
print(max(t))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
t=[0]*(200007)
for i in range(n):
	a,b,c=map(int,input().split())
	a*=2
	b*=2
	t[a-1]+=1
	t[b+1]-=1
for i in range(1,200007):t[i]+=t[i-1]
print(max(t))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
t=[0]*(200007)
for i in range(n):
	a,b,c=map(int,input().split())
	a*=2
	b*=2
	t[a-1]+=1
	t[b]-=1
for i in range(1,200007):t[i]+=t[i-1]
print(max(t))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
t=[0]*(200007)
for i in range(n):
	a,b,c=map(int,input().split())
	a*=2
	b*=2
	t[a-1]+=1
	t[b]-=1
for i in range(1,100007):t[i]+=t[i-1]
print(max(t))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
s=[set()for _ in range(c)]
t=[0]*(100007)
for i in range(n):
	a,b,c=map(int,input().split())
	if a in s[c-1]:a+=1
	s[c-1].add(b)
	t[a-1]+=1
	t[b]-=1
for i in range(1,100007):t[i]+=t[i-1]
print(max(t))

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
s=[set()for _ in range(c)]
t=[0]*(100002)
for i in range(n):
	a,b,c=map(int,input().split())
	if a in s[c-1]:a+=1
	s[c-1].add(b)
	t[a-1]+=1
	t[b]-=1
for i in range(1,100002):t[i]+=t[i-1]
print(max(t))

Submission status: Wrong Answer

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):
  if STC[i] == []:
    continue
  STC[i].sort(key=lambda x:x[0])
  s=STC[i][0][0]
  t=STC[i][0][1]
  if len(STC[i])==1:
    ST.append([s,0])
    ST.append([t,1])
    continue
  
  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: Wrong Answer

Solution code:
N,C = map(int,input().split())
ST = []
for _ in range(N):
  s,t,c = map(int,input().split())
  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: Wrong Answer

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

def main():
    N,C = map(int,input().split())
    X = [list(map(int,input().split())) for _ in range(N)]
    X = sorted(X,key = itemgetter(0,1))
    use = [0]
    for i in range(N):
        fin = heapq.heappop(use)
        if fin >= X[i][0]:
            heapq.heappush(use,fin)
        heapq.heappush(use,X[i][1])

    print(len(use))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,C=map(int,input().split())
da=[]
for i in range(n):
    s,t,c=map(int,input().split())
    da.append([s,-c])
    da.append([t,c])
ans=0
no=0
da=sorted(da)
for i in da:
    if i[1]>0:
        no-=1
    else:
        no+=1
    ans=max(ans,no)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,c = map(int, input().split())
channels = {i:[] for i in range(1,c+1)}
table = [0 for _ in range(200002)]
for _ in range(n):
    s,t,c = map(int, input().split())
    channels[c].append([s,t])

for ch, time in channels.items():
    for s,t in time:
        s,t = s*2-1, t*2
        table[s] += 1
        table[t] -= 1
ans = 0
for i in range(1,200002):
    table[i] += table[i-1]
    ans = max(ans, table[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

def inc(n):
  return n+1
def dec(n):
  return n-1

history = {}
for i in range(N):
  s,t,c = map(int,input().split())
  s *= 2
  t *= 2
  #print(history)
  if (t-1) in history and c in history[t-1]:
    history[t-1].pop(c)
  else:
    if t in history:
      history[t][c] = dec
    else:history[t] = {c:dec}
  if (s+1) in history and c in history[s+1]:
    history[s+1].pop(c)
  else:
    #history[s-0.5][c] = inc
    if s-1 in history:
      history[s-1][c] = inc
    else:
      history[s-1] = {c:inc}
maximum = 0
counter = 0
for i in range(100000*2):
  if i in history:
    for func in history[i].values():
      counter = func(counter)
    if counter > maximum:
      maximum = counter
#print(history)
print(maximum)

Submission status: Wrong Answer

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

def inc(n):
  return n+1
def dec(n):
  return n-1

history = {}
for i in range(N):
  s,t,c = map(int,input().split())
  s *= 2
  t *= 2
  #print(history)
  if (t-1) in history and c in history[t-1]:
    history[t-1].pop(c)
  else:
    if t in history:
      history[t][c] = dec
    else:history[t] = {c:dec}
  if (s+1) in history and c in history[s+1]:
    history[s+1].pop(c)
  else:
    #history[s-0.5][c] = inc
    if s in history:
      history[s][c] = inc
    else:
      history[s] = {c:inc}
maximum = 0
counter = 0
for i in range(100000*2):
  if i in history:
    for func in history[i].values():
      counter = func(counter)
    if counter > maximum:
      maximum = counter
#print(history)
print(maximum)

Submission status: Wrong Answer

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

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

for _ in range(N) :
    s, t, _ = map(int, input().split())
    imos[s] += 1
    imos[t+1] -= 1
    
for i in range(1, 10 ** 5 + 2) :
    imos[i] += imos[i-1]
    
print(max(imos))

Submission status: Wrong Answer

Solution code:

N,C = map(int,input().split())

slis = [0] * (10 ** 5 + 1)
tlis = [0] * (10 ** 5 + 1)

ans = 0

for i in range(N):

    s,t,c = map(int,input().split())

    slis[s] += 1
    tlis[t] += 1

now = 0
for i in range(10 ** 5):

    i += 1
    now += slis[i]
    now -= tlis[i-1]
    ans = max(ans,now)

print (ans)

Submission status: Wrong Answer

Solution code:
N, C = map(int,input().split())
T = [[] for _ in range(C+1)]
for _ in range(N):
    s,t,c = map(int,input().split())
    T[c].append([s,t])
result = []
for i in range(len(T)):
    times = T[i]
    times.sort()
    idx = 0
    for s, t in times:
        if idx != 0 and result[-1][1] == s:
            result[-1] = (result[-1][0], t)
        else:
            result.append((s,t))
            idx = 1
            
import numpy as np

A = np.zeros(10**5+10,dtype=np.int32)
for u in T:
    if len(u) == 0:
        continue
    else:
        for times in u:
            A[times[0]-1] += 1
            A[times[1]] -= 1
print(max(np.cumsum(A)))

Submission status: Wrong Answer

Solution code:
N, C = map(int,input().split())
T = [[] for _ in range(C+1)]
for _ in range(N):
    s,t,c = map(int,input().split())
    T[c].append([s,t])
result = []
for i in range(len(T)):
    times = T[i]
    times.sort()
    idx = 0
    for s, t in times:
        if result and result[-1][1] == s:
            result[-1] = (result[-1][0], t)
        else:
            result.append((s,t))

import numpy as np

A = np.zeros(10**5+10,dtype=np.int32)
for u in T:
    if len(u) == 0:
        continue
    else:
        for times in u:
            A[times[0]-1] += 1
            A[times[1]] -= 1
print(max(np.cumsum(A)))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,c = inpl()
s = [inpl() for i in range(n)]
s.sort()
rec = [0]
for i in range(n):
    flag = False
    for j in range(len(rec)):
        if s[i][0] > rec[j]:
            rec[j] = s[i][1]
            
            flag = True
            break
    if flag == False:
        rec.append(s[i][1])
print(len(rec))

Submission status: Wrong Answer

Solution code:
import numpy as np

LIM = int(10e5)
time = [0] * (LIM+1)
N,C = list(map(int,input().split(" ")))
for _ in range(N):
    s,t,_= list(map(int, input().split(" ")))
    time[s] += 1
    time[t + 1] += -1
# print(time[:100])
ruiseki = np.cumsum(time)


# print(ruiseki[:10])
print(np.max(ruiseki[1:]))

Submission status: Wrong Answer

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

N, C = map(int, input().split())

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

#print(STC)

import heapq
h = []
for s, t, c in STC:
    heapq.heappush(h, (s-0.5, 0, c))
    heapq.heappush(h, (t, 1, c))

ans = 0
cnt = 0
rec = [0] * (C+1)
while h:
    t, flag, c = heapq.heappop(h)
    if flag == 0:
        if rec[c] == 0:
            rec[c] += 1
            cnt += 1
        else:
            rec[c] += 1
    else:
        cnt -= 1
        rec[c] -= 1
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

N, C = map(int, input().split())

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

#print(STC)

import heapq
h = []
for s, t, c in STC:
    heapq.heappush(h, (s-0.5, 0, c))
    heapq.heappush(h, (t, 1, c))

ans = 0
cnt = 0
rec = [0] * (C+1)
while h:
    t, flag, c = heapq.heappop(h)
    if flag == 0:
        if rec[c] == 0:
            rec[c] = 1
            cnt += 1
        else:
            pass
    else:
        cnt -= 1
        rec[c] = 0
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

N, C = map(int, input().split())

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

#print(STC)

import heapq
h = []
for s, t, c in STC:
    heapq.heappush(h, (s-0.5, 0))
    heapq.heappush(h, (t-0.5, 1))

ans = 0
cnt = 0
while h:
    t, flag = heapq.heappop(h)
    if flag == 0:
        cnt += 1
    else:
        cnt -= 1
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

N, C = map(int, input().split())

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

#print(STC)

import heapq
h = []
for s, t, c in STC:
    heapq.heappush(h, (s, 0))
    heapq.heappush(h, (t+0.5, 1))

ans = 0
cnt = 0
while h:
    t, flag = heapq.heappop(h)
    if flag == 0:
        cnt += 1
    else:
        cnt -= 1
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

N, C = map(int, input().split())

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

#print(STC)

import heapq
h = []
for s, t, c in STC:
    heapq.heappush(h, (s-0.5, 0))
    heapq.heappush(h, (t, 1))

ans = 0
cnt = 0
while h:
    t, flag = heapq.heappop(h)
    if flag == 0:
        cnt += 1
    else:
        cnt -= 1
    ans = max(ans, cnt)
print(ans)