Problem:


Score : 400 points

Problem Statement

Joisino is planning to record N TV programs with recorders.

The TV can receive C channels numbered 1 through C.

The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.

Here, there will never be more than one program that are broadcast on the same channel at the same time.

When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).

Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.

Constraints

1≤N≤10^5

1≤C≤30

1≤s_i<t_i≤10^5

1≤c_i≤C

If c_i=c_j and i≠j, either t_i≤s_j or s_i≥t_j.

All input values are integers.

Input

Input is given from Standard Input in the following format:

N C
s_1 t_1 c_1
:
s_N t_N c_N

Output

When the minimum required number of recorders is x, print the value of x.

Sample Input 1

3 2
1 7 2
7 8 1
8 12 1

Sample Output 1

2

Two recorders can record all the programs, for example, as follows:

With the first recorder, record Channel 2 from time 1 to time 7. The first program will be recorded. Note that this recorder will be unable to record other channels from time 0.5 to time 7.

With the second recorder, record Channel 1 from time 7 to time 12. The second and third programs will be recorded. Note that this recorder will be unable to record other channels from time 6.5 to time 12.

Sample Input 2

3 4
1 3 2
3 4 4
1 4 3

Sample Output 2

3

There may be a channel where there is no program to record.

Sample Input 3

9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3

Sample Output 3

2



Sample input:
3 2
1 7 2
7 8 1
8 12 1


Sample output:
2

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, C = map(int, input().split())
T = 10**5
time = [[0 for _ in range(2*T+1)] for _ in range(C)] # 0.5秒刻み
for loop in range(n):
    s, t, c = map(int, input().split())
    c -= 1
    time[c][2*s-1] += 1
    time[c][2*t] -= 1

for c in range(C):
    for t in range(1, 2*T+1):
        time[c][t] += time[c][t-1]

ans = 0
for t in range(2*T+1):
    a = 0
    for c in range(C):
        a += time[c][t]
    ans = max(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,c = map(int,input().split())
#stc = [list(map(int,input().split())) for _ in range(n)]
a = [0]*10**5
for _ in range(n):
  s,t,c = map(int,input().split())
  a[s-1:t] = [i+1 for i in a[s-1:t]]
print(max(a))

Submission status: Wrong Answer

Solution code:
n,C=map(int,input().split())
schedule=[]
time=[[0 for i in range(C)] for j in range(2*10**5+2)]

for i in range(n):
    s,t,c=map(int,input().split())
    if time[2*s][c-1]==-1:
        time[2*s][c-1]+=1
    else:
        time[2*s-1][c-1]+=1
    time[2*t][c-1]-=1

for i in range(2*10**5+1):
    for j in range(C):
        time[i+1][j]+=time[i][j]
ans=1
for i in range(2*10**5+2):
    tmp=0
    for j in range(C):
        tmp+=time[i][j]
    ans=max(ans,tmp)

print(ans)

Submission status: Wrong Answer

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

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

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

ans=1
for i in range(10**5+1):
    tmp=0
    for j in range(C):
        tmp+=time[i][j]
    ans=max(ans,tmp)

print(ans)

Submission status: Wrong Answer

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

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

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

ans=0
for i in range(10**5+1):
    tmp=0
    for j in range(C):
        tmp+=time[i][j]
    ans=max(ans,tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-1,t1))
                s1 = j[0]
                t1 = j[1]
    st2[i].append((s1-1,t1))

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

for i in st2:
    for j in i:
        imos[j[0]] += 1
        imos[j[1]+1] -= 1

for i in range(10**5+5):
    imos[i+1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-0.5,t1))
                s1 = j[0]
                t1 = j[1]
    st2[i].append((s1-0.5,t1))

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

for i in st2:
    for j in i:
        imos[int(j[0]*2)-1] += 1
        imos[int(j[1]*2)] -= 1

for i in range(2*10**5+5):
    imos[i+1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-0.5,t1))
                s1 = j[0]
                t1 = j[1]
    st2[i].append((s1-0.5,t1))

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

for i in st2:
    for j in i:
        imos[int(j[0]*2)] += 1
        imos[int(j[1]*2)+1] -= 1

for i in range(2*10**5+5):
    imos[i+1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-0.5,t1))
                s1 = j[0]
                s2 = j[1]
    st2[i].append((s1-0.5,t1))

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

for i in st2:
    for j in i:
        imos[int(j[0]*2)] += 1
        imos[int(j[1]*2)+1] -= 1

for i in range(2*10**5+5):
    imos[i+1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-0.5,t1))
                s1 = j[0]
                s2 = j[1]
    st2[i].append((s1-0.5,t1))

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

for i in st:
    for j in i:
        imos[int(j[0]*2)] += 1
        imos[int(j[1]*2)+1] -= 1

for i in range(2*10**5+5):
    imos[i+1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-1,t1))
                s1 = j[0]
                s2 = j[1]
    st2[i].append((s1-1,t1))

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

for i in st:
    for j in i:
        imos[j[0]] += 1
        imos[j[1]+1] -= 1

for i in range(10**5+5):
    imos[i+1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

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

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-1,t1))
                s1 = j[0]
                s2 = j[1]
    st2[i].append((s1-1,t1))

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

for i in st:
    for j in i:
        imos[j[0]] += 1
        imos[j[1]+1] -= 1

for i in range(10**5+5):
    imos[i+1] += imos[i]

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

n,c = map(int, input().split())
stc = [list(map(int, input().split())) for i in range(n)]
finish = [1] * (c+1)
record = [0] * (10 ** 5 + 2) 
ans = 1
for s,t,c in stc:
  if finish[c] != s:
    s -= 1
  finish[c] = t
  record[s] += 1
  record[t] -= 1
ans = max(list(accumulate(record)))
assert ans >= 1
assert ans <= n
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

n,c = map(int, input().split())
stc = [list(map(int, input().split())) for i in range(n)]
finish = [1] * (c+1)
record = [0] * (10 ** 5 + 2) 
ans = 1
for s,t,c in stc:
  if finish[c] != s:
    s -= 1
  finish[c] = t
  record[s] += 1
  record[t] -= 1
ans = max(list(accumulate(record)))
print(ans)

Submission status: Wrong Answer

Solution code:
#recording
N,C=map(int,input().split())
plus=[[0 for i in range(2*10**5+200)]for j in range(C+1)]
minus=[[0 for i in range(2*10**5+200)]for j in range(C+1)]
for _ in range(N):
    s,t,c=map(int,input().split())
    plus[c][2*s-1]=1
    minus[c][2*t]=-1
for c in range(1,C+1):
    for i in range(1,2*10**5+100):
        plus[c][i]+=plus[c][i-1]
        minus[c][i]+=minus[c][i-1]
ans=0
for i in range(2*10**5+100):
    sums=0
    for k in range(1,C+1):
        sums+=(plus[k][i]+minus[k][i])
    ans=max(sums,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

MAX_T = 2 * 10 ** 5

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

n_program = [0 for _ in range(MAX_T + 1)]

for s, t in time:
    n_program[s] += 1
    n_program[t + 1] -= 1

n_program = accumulate(n_program)

answer = max(n_program)
print(answer)

Submission status: Wrong Answer

Solution code:
#recording
N,C=map(int,input().split())
plus=[[0 for i in range(2*10**5+200)]for j in range(C+1)]
minus=[[0 for i in range(2*10**5+200)]for j in range(C+1)]
for _ in range(N):
    s,t,c=map(int,input().split())
    plus[c][2*s-1]=1
    minus[c][2*t+1]=-1
for c in range(1,C+1):
    for i in range(1,2*10**5+100):
        plus[c][i]+=plus[c][i-1]
        minus[c][i]+=minus[c][i-1]
ans=0
for i in range(2*10**5+100):
    sums=0
    for k in range(1,C+1):
        sums+=(plus[k][i]+minus[k][i])
    ans=max(sums,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#recording
N,C=map(int,input().split())
plus=[[0 for i in range(10**5+500)]for j in range(31)]
minus=[[0 for i in range(10**5+500)]for j in range(31)]
for _ in range(N):
    s,t,c=map(int,input().split())
    plus[c][s-1]=1
    minus[c][t]=-1   
for c in range(1,C+1):
    for i in range(1,10**5+100):
        plus[c][i]+=plus[c][i-1]
        minus[c][i]+=minus[c][i-1]
ans=0
for i in range(10**5+100):
    sums=0
    for k in range(1,C+1):
        sums+=(plus[k][i]+minus[k][i])    
    ans=max(sums,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#recording
N,C=map(int,input().split())
plus=[[0 for i in range(10**5+500)]for j in range(31)]
minus=[[0 for i in range(10**5+500)]for j in range(31)]
for _ in range(N):
    s,t,c=map(int,input().split())
    plus[c][s]=1
    minus[c][t+1]=-1   
for c in range(1,C+1):
    for i in range(1,10**5+100):
        plus[c][i]+=plus[c][i-1]
        minus[c][i]+=minus[c][i-1]
ans=0
for i in range(10**5+100):
    sums=0
    for k in range(1,C+1):
        sums+=(plus[k][i]+minus[k][i])    
    ans=max(sums,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#recording
N,C=map(int,input().split())
plus=[[0 for i in range(10**5+10)]for j in range(31)]
minus=[[0 for i in range(10**5+10)]for j in range(31)]
for _ in range(N):
    s,t,c=map(int,input().split())
    plus[c][s]=1
    minus[c][t+1]=-1
    
for c in range(1,C+1):
    for i in range(1,10**5+1):
        plus[c][i]+=plus[c][i-1]
        minus[c][i]+=minus[c][i-1]
ans=0
for i in range(10**5+1):
    sums=0
    for k in range(1,C+1):
        sums+=(plus[k][i]+minus[k][i])    
    ans=max(sums,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#ABC080-D Recording
"""
録画したい番組n個、チャンネルc個
同時間に重複する番組の個数を求めよ
但し、番組の時刻をs-tとして、sを含んでtを含まないとして良い
解法：
imos法。
s-1に+1,tに-1して解凍したときのmax。
時刻の制約は10**5なので、そのままリストとして作成してよい。
もしかしたら連続する同チャンネルの番組は一つとしてカウントして良い？
"""
import sys
from operator import itemgetter
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
stc = []
for i in range(n):
    stc.append(list(map(int,readline().split())))
stc.sort(key=itemgetter(2))
res = []
keep = 0
for i in range(0,n-1):
    if stc[i][2]==stc[i+1][2]:
        if stc[i][1] == stc[i+1][0]:
            continue
    res.append([stc[keep][0],stc[i][1],stc[i][2]])
    keep = i+1
res.append([stc[keep][0],stc[-1][1],stc[-1][2]])
imos = [0]*(10**5+1)
for i in range(len(res)):
    s,t = res[i][0],res[i][1]
    imos[s-1] += 1
    imos[t] -= 1

for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))

Submission status: Wrong Answer

Solution code:
#ABC080-D Recording
"""
録画したい番組n個、チャンネルc個
同時間に重複する番組の個数を求めよ
但し、番組の時刻をs-tとして、sを含んでtを含まないとして良い
解法：
imos法。
s-1に+1,tに-1して解凍したときのmax。
時刻の制約は10**5なので、そのままリストとして作成してよい。
もしかしたら連続する同チャンネルの番組は一つとしてカウントして良い？
"""
import sys
from operator import itemgetter
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
stc = []
for i in range(n):
    stc.append(list(map(int,readline().split())))
stc.sort(key=itemgetter(2))
flags = [0]*n
res = []
keep = 0
for i in range(0,n-1):
    if stc[i][2]==stc[i+1][2]:
        if stc[i][1] == stc[i+1][0]:
            continue
    res.append([stc[keep][0],stc[i][1],stc[i][2]])
    keep = i+1
res.append([stc[keep][0],stc[-1][1],stc[-1][2]])
stc = res
imos = [0]*(10**5+1)
for i in range(len(stc)):
    s,t,ch = stc[i][0],stc[i][1],stc[i][2]
    imos[s-1] += 1
    imos[t] -= 1


for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))

Submission status: Wrong Answer

Solution code:
#ABC080-D Recording
"""
録画したい番組n個、チャンネルc個
同時間に重複する番組の個数を求めよ
但し、番組の時刻をs-tとして、sを含んでtを含まないとして良い
解法：
imos法。
s-1に+1,tに-1して解凍したときのmax。
時刻の制約は10**5なので、そのままリストとして作成してよい。
もしかしたら連続する同チャンネルの番組は一つとしてカウントして良い？
"""
import sys
from operator import itemgetter
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
stc = []
for i in range(n):
    stc.append(list(map(int,readline().split())))
stc.sort(key=itemgetter(2))
flags = [0]*n
res = []
for i in range(1,n):
    if stc[i][0] == stc[i-1][1]:
        if stc[i][2] == stc[i-1][2]:
            res.append([stc[i-1][0],stc[i][1],stc[i][2]])
            flags[i-1] = 1
            flags[i] = 1
for i in range(n):
    if not flags[i]:
        res.append(stc[i])
stc = res
        
imos = [0]*(10**5+1)
for i in range(len(stc)):
    s,t,ch = stc[i][0],stc[i][1],stc[i][2]
    imos[s-1] += 1
    imos[t] -= 1


for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))

Submission status: Wrong Answer

Solution code:
#ABC080-D Recording
"""
録画したい番組n個、チャンネルc個
同時間に重複する番組の個数を求めよ
但し、番組の時刻をs-tとして、sを含んでtを含まないとして良い
解法：
imos法。
s-1に+1,tに-1して解凍したときのmax。
時刻の制約は10**5なので、そのままリストとして作成してよい。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,c = map(int,readline().split())
imos = [0]*(10**5+1)
for i in range(n):
    s,t,ch = map(int,readline().split())
    imos[s-1] += 1
    imos[t] -= 1


for i in range(1,len(imos)):
    imos[i] += imos[i-1]

print(max(imos))

Submission status: Wrong Answer

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

import heapq  # heapqライブラリのimport
tv=[-1]
heapq.heapify(tv)  # リストを優先度付きキューへ
#print(heapq.heappop(a))  # 最小値の取り出し
#heapq.heappush(a, -2)
ch=[0]*c

for _ in range(n):
    s,t,c=map(int,input().split())
    temp=heapq.heappop(tv)
    if temp<s:
        heapq.heappush(tv,t)
    elif temp==s and ch[c-1]==temp:
        heapq.heappush(tv, t)
    else:
        heapq.heappush(tv,temp)
        heapq.heappush(tv,t)
    ch[c-1]=t
    #print(tv)
print(len(tv))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import numpy as np
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    MAX = 10 ** 5 + 2
    vals = [0] * MAX
    D = defaultdict(list)
    for _ in range(N):
        s, t, c = map(int, input().split())
        D[c].append((s, t))

    for k, v in D.items():
        prev = None
        for s, t in v:
            if prev == s:
                vals[prev + 1] += 1
                vals[t + 1] -= 1
            else:
                vals[s] += 1
                vals[t + 1] -= 1
            prev = t
    cumsum = np.cumsum(vals)
    ans = max(cumsum)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    MAX = 10 ** 5 + 2
    vals = [0] * MAX
    for _ in range(N):
        s, t, c = map(int, input().split())
        vals[s] += 1
        vals[t + 1] -= 1
    cumsum = np.cumsum(vals)
    ans = max(cumsum)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    N, C = map(int, input().split())
    tv = np.zeros(2*10**5+1)
    ch = set()
    for i in range(N):
        s,t,c = map(int, input().split())
        if((s, t, c) not in ch):
            ch.add((s, t, c))
            tv[(s*2-1):2*t] += 1
    print(int(np.max(tv)))
   
main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    N, C = map(int, input().split())
    tv = np.zeros(2*10**5+1)  
    for i in range(N):
        s,t,c = map(int, input().split())
        tv[(s*2-1):2*t] += 1

    print(int(np.max(tv)))
   
main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    N, C = map(int, input().split())
    tv = np.zeros(2*10**5+1)  
    for i in range(N):
        s,t,c = map(int, input().split())
        tv[(s*2-1):(2*t+1)] += 1

    print(int(np.max(tv)))
   
main()

Submission status: Wrong Answer

Solution code:
# ある時点の重複番組数を前からカウントして、最大値が答え
# s順に並べて、ループごとに重複数を増やしつつ、
# 終了キューにtを追加
# 番組追加するごとに終了キューの中身をチェック
# 同じチャンネルだったら、終了キューt <= 現在時刻 のときに終了キューから外せる
# 違うチャンネルだったら、終了キューt < 現在時刻となる

N,C = map(int,input().split())
import heapq
endq = []
heapq.heapify(endq)
maxval = 0
cur = 0
progs = [None] * N
for i in range(N):
  progs[i] = list(map(int,input().split()))

progs = sorted(progs,key = lambda x:x[0])
for i in range(N):
  s,t,c = progs[i]
  cur += 1
  heapq.heappush(endq,(t,c))
#  print(s,t,c,"録画開始 録画中件数:",cur)
  while endq:
    endt,endc = heapq.heappop(endq)
#    print("終了チェック",endt,endc)
    if endc == c:
      if endt <= s:
        cur -= 1
#        print("終了 録画中件数",cur)
      else:
        heapq.heappush(endq,(endt,endc))
#        print("継続 録画中件数",cur)
        break
    else:
      if endt < s:
        cur -= 1
#        print("終了 録画中件数",cur)
      else:
        heapq.heappush(endq,(endt,endc))
#        print("継続 録画中件数",cur)
        break
#  print(s,"録画中件数:",cur,"録画中",endq)
#  print("---")
  if maxval < cur:
    maxval = cur

print(maxval)

Submission status: Wrong Answer

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

LEN = 10 ** 5 + 7
d = [0] * LEN
for s, t, c in X:
    d[s] += 1
    d[t + 1] -= 1
    
for i in range(LEN - 1):
    d[i + 1] += d[i]
    
print(max(d))

Submission status: Wrong Answer

Solution code:
n,C = map(int,input().split())
imos = [0]*(10**5+2)
ch = [set() for _ in range(C)]
for i in range(n):
    s,t,c = map(int,input().split())
    c -= 1
    if s in ch[c]:
        ch[c].remove(s)
        imos[s+1] +=1
    else:
        ch[c].add(s)
        imos[s-1] += 1
    if t in ch[c]:
        ch[c].remove(t)
        imos[t-1] -= 1
    else:
        ch[c].add(t)
        imos[t+1] -= 1
ans = 0
cnt = 0
for i in imos:
    cnt += i
    ans = max(ans,cnt)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
for i in range(N):
    s, t, c = map(int, input().split())
    start = (s-0.5, 1)
    end = (t, 0)
    events.append(start)
    events.append(end)
    if tmax < t:
        tmax = t
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

Submission status: Wrong Answer

Solution code:
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
for i in range(N):
    s,t,c = map(int, input().split())
    start = (s-0.5, 1)
    end = (t, 0)
    events.append(start)
    events.append(end)
    if tmax < t:
        tmax = t
events.sort()
idx = 0
cnt = 0
res = 0
for t in range(tmax+1):
    while events[idx][0] < t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        else:
            cnt -= 1
        idx += 1
print(res)

Submission status: Wrong Answer

Solution code:
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
for i in range(N):
    s,t,c = map(int, input().split())
    start = (s, 0)
    end = (t, 1)
    events.append(start)
    events.append(end)
    if tmax < t:
        tmax = t
events.sort()
idx = 0
cnt = 0
res = 0
for t in range(tmax+1):
    while events[idx][0] < t:
        event = events[idx]
        if event[1] == 0:
            cnt += 1
            if res < cnt:
                res = cnt
        else:
            cnt -= 1
        idx += 1
print(res)

Submission status: Wrong Answer

Solution code:
N, C = tuple(map(int, input().split()))
events = []
eps = 0.01
tmax = 0
for i in range(N):
    s,t,c = map(int, input().split())
    start = (s, 0)
    end = (t+eps, 1)
    events.append(start)
    events.append(end)
    if tmax < t:
        tmax = t+1
events.sort()
idx = 0
cnt = 0
res = 0
for t in range(tmax):
    while events[idx][0] <= t:
        event = events[idx]
        if event[0] <= t:
            if event[1] == 0:
                cnt += 1
                if res < cnt:
                    res = cnt
            else:
                cnt -= 1
        idx += 1
print(res)

Submission status: Wrong Answer

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

event_list=[]
for i in range(N):
  s,t,c=map(int,input().split())
  event_list.append((s-0.5,1))
  event_list.append((t,-1))
event_list.sort()
#print(event_list)

answer=0
cnt=0
for t,f in event_list:
  if f==1:
    cnt+=1
    answer=max(answer,cnt)
  else:
    cnt-=1

print(answer)

Submission status: Wrong Answer

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

N, C = [int(x) for x in input().split()]
imos = [0]*(10**6 + 2)
stc = [[] for _ in range(31)]
for _ in range(N):
    tmp = [int(x) for x in input().split()]
    stc[tmp[2]].append([tmp[0], tmp[1]])
print(stc)
for i in range(C + 1):
    if len(stc[i]) == 0:
        continue
    stc[i].sort()
    s, t = stc[i][0][0], stc[i][0][1]
    new_stc_i = []
    flag = 1
    for j in range(1, len(stc[i])):
        flag = 0
        if t == stc[i][j][0]:
            t = stc[i][j][1]
            flag = 1
        else:
            new_stc_i.append([s, t])
            s = stc[i][j][0]
            t = stc[i][j][1]
    if flag:
        new_stc_i.append([s, t])
    stc[i] = new_stc_i

for i in range(C + 1):
    stc_i = stc[i]
    for j in stc_i:
        s, t = j 
        s *= 10
        t *= 10
        imos[max(0, s - 5)] += 1
        imos[t] -= 1

from itertools import accumulate

csum = list(accumulate(imos))

print(max(csum))

Submission status: Wrong Answer

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

N, C = [int(x) for x in input().split()]
imos = [0]*(10**6 + 2)

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

from itertools import accumulate

csum = list(accumulate(imos))

print(max(csum))

Submission status: Wrong Answer

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

N, C = [int(x) for x in input().split()]
imos = [0]*(10**6 + 2)

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

from itertools import accumulate

csum = list(accumulate(imos))

print(max(csum))

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from heapq import heappush
    N, C = map(int, input().split())
    pros = [tuple(map(int, input().split())) for _ in range(N)]
    pros.sort(key=lambda x: x[1])
    machines = [] # [(time, channel)] heapq
    for s, t, c in pros:
        for i in range(len(machines)):
            if s > machines[i][0] or (s == machines[i][0] and c == machines[i][1]):
                machines.pop(i)
                heappush(machines, (t, c))
                break
        else:
            heappush(machines, (t, c))
    print(len(machines))



if __name__ == '__main__':
    main()