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:
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # チャンネルごとにimos配列
    imos = [[0]*num for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c0 = map(int, input().split())
        if imos[c0-1][s*2] < 0 and imos[c0-1][t*2-1] > 0:
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2-1] = 0
        elif imos[c0-1][s*2] < 0:            
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2] += 1
        elif imos[c0-1][t*2-1] > 0:    
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2-1] = 0
        else:
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2] -= 1
    ans = [0 for _ in range(num)]
    for i in range(c):
        for j in range(1, num):
            imos[i][j] += imos[i][j-1]
            ans[j] += imos[i][j]
    print(max(ans))
    
if __name__ == '__main__':
    Recording()

Submission status: Wrong Answer

Solution code:
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # チャンネルごとにimos配列
    imos = [[0]*num for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c0 = map(int, input().split())
        if imos[c0-1][s*2] < 0 and imos[c0-1][t*2-1] > 0:
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2-1] = 0
        elif imos[c0-1][s*2] < 0:            
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2-1] += 1
        elif imos[c0-1][t*2-1] > 0:    
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2-1] = 0
        else:
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2] -= 1
    ans = [0 for _ in range(num)]
    for i in range(c):
        for j in range(1, num):
            imos[i][j] += imos[i][j-1]
            ans[j] += imos[i][j]
    print(max(ans))
    
if __name__ == '__main__':
    Recording()

Submission status: Wrong Answer

Solution code:
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # チャンネルごとにimos配列
    imos = [[0]*num for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c0 = map(int, input().split())
        if imos[c0-1][s*2-1] < 0 and imos[c0-1][t*2] > 0:
            imos[c0-1][s*2-1] = 0
            imos[c0-1][t*2] = 0
        elif imos[c0-1][s*2-1] < 0:            
            imos[c0-1][s*2-1] = 0
            imos[c0-1][t*2] += 1
        elif imos[c0-1][t*2] > 0:    
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2] = 0
        else:
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2] -= 1
            
    ans = [0 for _ in range(num)]
    for i in range(c):
        for j in range(1, num):
            imos[i][j] += imos[i][j-1]
            ans[j] += imos[i][j]
    print(max(ans))
    
if __name__ == '__main__':
    Recording()

Submission status: Wrong Answer

Solution code:
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # チャンネルごとにimos配列
    imos = [[0]*num for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c0 = map(int, input().split())
        imos[c0-1][s*2-1] += 1
        imos[c0-1][t*2] -= 1
    ans = [0 for _ in range(num)]

    for i in range(c):
        for j in range(1, num):
            imos[i][j] += imos[i][j-1]
            ans[j] += imos[i][j]
    print(max(ans))
    
if __name__ == '__main__':
    Recording()

Submission status: Wrong Answer

Solution code:
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 
    INF = float('inf')
    
    # imos配列
    imos = [0 for _ in range(num)]
    loc = [[INF, 0] for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c = map(int, input().split())
        if loc[c-1][0] != t and loc[c-1][1] != s:
            imos[s*2-1] += 1
            imos[t*2] -= 1
        elif loc[c-1][0] == t:
            imos[loc[c-1][0]*2-1] -= 1
            imos[s*2-1] += 1            
        elif loc[c-1][1] == s:
            imos[loc[c-1][0]*2] += 1
            imos[t*2] -= 1
        loc[c-1][0] = min(loc[c-1][0], s)
        loc[c-1][1] = max(loc[c-1][1], t)
    for i in range(1, num):
        imos[i] += imos[i-1]
    print(max(imos))
    
if __name__ == '__main__':
    Recording()

Submission status: Wrong Answer

Solution code:
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # imos配列
    imos = [0 for _ in range(num)]

    # imos
    for _ in range(n):
        s, t, c = map(int, input().split())
        imos[s*2-1] += 1
        imos[t*2] -= 1
    for i in range(1, num):
        imos[i] += imos[i-1]
        
    print(max(imos))
    
if __name__ == '__main__':
    Recording()

Submission status: Wrong Answer

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

for i in range(C+1):
    for j in range(len(T[i])):
        s, t = T[i][j]
        if K[i][s] == 0:
            T[i][j][0] -= 0.5
P = [0]*(10**6)
for i in range(C+1):
    for j in range(len(T[i])):
        for k in range(int(2*T[i][j][0]), 2*T[i][j][1]+1):
            P[k] += 1
print(max(P))

Submission status: Wrong Answer

Solution code:
from sys import stdin

def getval():
    n,c = map(int,stdin.readline().split())
    s = [list(map(int,stdin.readline().split())) for i in range(n)]
    return n,c,s

def main(n,c,s):
    arr = [[0 for i in range(c)] for i in range(10**5)]
    for i in s:
        ch = i[2]-1
        for j in range(i[0]-1,i[1]):
            arr[j][ch] += 1
    ans = 0
    for i in range(10**5):
        loc = arr[i]
        temp = 0
        for j in range(c):
            temp += loc[j]
        ans = max(temp,ans)
    print(ans)

if __name__=="__main__":
    n,c,s = getval()
    main(n,c,s)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


def main():
    n, c = map(int, input().split())
    p = [[] for _ in range(c + 1)]
    for _ in range(n):
        *st, cc = map(int, input().split())
        p[cc].append(st)
    all_p = [0] * (10 ** 5 + 10)
    for pp in p:
        if len(pp) == 0:
            continue
        pp.sort()
        last_start, last_end = pp[0]
        for start, end in pp[1:]:
            if start == last_end:
                last_end = start
            else:
                all_p[last_start - 1] += 1
                all_p[last_end] -= 1
                last_start, last_end = start, end
        all_p[last_start - 1] += 1
        all_p[last_end] -= 1
    print(max(accumulate(all_p)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heapify, heappush


def main():
    n, c = map(int, input().split())
    program = [[] for _ in range(c)]
    for _ in range(n):
        s, t, cc = map(int, input().split())
        cc -= 1
        s *= 2
        t *= 2
        program[cc].append([s - 1, t])
    all_p = []
    for i in range(c):
        if len(program[i]) == 0:
            continue
        now = program[i]
        now.sort(key=lambda x: x[1])
        last_begin, last_end = now[0]
        for begin, end in now[1:]:
            if begin + 1 == last_end:
                last_end = end
            else:
                all_p.append([last_begin, last_end, i])
                last_begin = begin
                last_end = end
        all_p.append([last_begin, last_end, i])
    all_p.sort(key=lambda x: x[1])
    q = [(-1, -1)]
    heapify(q)
    for begin, end, now_channel in all_p:
        last_end, channel = q[0]
        if last_end < begin or now_channel == channel:
            heappop(q)
        heappush(q, (end, now_channel))
    print(len(q))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heapify, heappush


def main():
    n, c = map(int, input().split())
    program = [[] for _ in range(c)]
    for _ in range(n):
        s, t, cc = map(int, input().split())
        cc -= 1
        s *= 2
        t *= 2
        program[cc].append([s - 1, t])
    all_p = []
    for i in range(c):
        if len(program[i]) == 0:
            continue
        now = program[i]
        now.sort(key=lambda x: x[1])
        last_begin, last_end = now[0]
        for begin, end in now[1:]:
            if begin + 1 == last_end:
                last_end = end
            else:
                all_p.append([last_begin, last_end])
                last_begin = begin
                last_end = end
        all_p.append([last_begin, last_end])
    all_p.sort(key=lambda x: x[1])
    q = []
    heapify(q)
    for begin, end in all_p:
        if q:
            now = heappop(q)
            if now >= begin:
                heappush(q, now)
        heappush(q, end)
    print(len(q))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heapify, heappush


def main():
    n, c = map(int, input().split())
    program = [[] for _ in range(c)]
    for _ in range(n):
        *st, cc = map(int, input().split())
        cc -= 1
        program[cc].append(st)
    all_p = []
    for i in range(c):
        if len(program[i]) == 0:
            continue
        now = program[i]
        now.sort(key=lambda x: x[1])
        last_begin, last_end = now[0]
        for begin, end in now[1:]:
            if begin == last_end:
                last_end = end
            else:
                all_p.append([last_begin, last_end])
                last_begin = begin
                last_end = end
        all_p.append([last_begin, last_end])
    all_p.sort(key=lambda x: x[1])
    q = []
    heapify(q)
    for begin, end in all_p:
        if q:
            now = heappop(q)
            if now >= begin:
                heappush(q, now)
        heappush(q, end)
    print(len(q))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappop, heapify, heappush


def main():
    n, c = map(int, input().split())
    program = [[] for _ in range(c)]
    for _ in range(n):
        *st, cc = map(int, input().split())
        cc -= 1
        program[cc].append(st)
    all_p = []
    for i in range(c):
        if len(program[i]) == 0:
            continue
        now = program[i]
        now.sort(key=lambda x: x[1])
        last_begin, last_end = program[i][0]
        for begin, end in program[i][1:]:
            if begin == last_end:
                last_end = end
            else:
                all_p.append([last_begin, last_end])
                last_begin = begin
                last_end = end
        all_p.append([last_begin, last_end])
    all_p.sort(key=lambda x: x[1])
    q = []
    heapify(q)
    for begin, end in all_p:
        if q:
            now = heappop(q)
            if now >= begin:
                heappush(q, now)
        heappush(q, end)
    print(len(q))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

for i in range(len(ans)-1):
    ans[i+1] += ans[i]
print(max(ans))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
cusum = [[0 for j in range(10**5+1)] for i in range(C+1)]
for i in range(N):
    s, t, c = map(int, input().split())
    cusum[c][s] = 1
    cusum[c][t] = -1
ans = 0
s = 0
for j in range(10**5+1):
    cp = 0
    cm = 0
    for i in range(C+1):
        if cusum[i][j] == 1:
            cp += 1
        elif cusum[i][j] == -1:
            cm += 1
    s += cp
    ans = max(s, ans)
    s -= cm

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    with open(0) as f:
        N, C = map(int, f.readline().split())
        Rec = [tuple(map(int, f.readline().split())) for _ in range(N)]
    
    time_line_by_channel = np.array([[0] * (10**5+1) for _ in range(C+1)])
    #チャンネルごとにタイムラインを作成(累積和分解)
    for s, t, c in Rec:
        if time_line_by_channel[c, s] == -1:
            time_line_by_channel[c, s] += 1
        else:    
            time_line_by_channel[c,s-1] += 1
        time_line_by_channel[c,t] += -1
    #タイムライン結合
    joined_timeline = np.sum(time_line_by_channel, axis=0)
    #累積和
    joined_timeline = np.cumsum(joined_timeline)
    ans = max(joined_timeline)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,C = map(int,input().split())
point_Start = [0] * (2*10**5+10)
point_End = [0] * (2*10**5+10)
pointchannel_end = defaultdict(int)
ls = [[0,0,0] for _  in range(N)]

for i in range(N):
    start,end,channel = map(int,input().split())
    ls[i] = [start, end, channel]

for i in range(N):
    start,end,channel = ls[i]
    # 同じチャンネルで、繋げられるものがないか
    if pointchannel_end[(2*start,channel)] > 0:
        point_End[2*start] -= 1
        point_End[2*end] += 1
        pointchannel_end[(2*start,channel)] -= 1

    else:
        point_Start[2*start-1] += 1
        point_End[2*end] += 1
    pointchannel_end[(2*end,channel)] = 1

now = 0
ans = 0
for i in range(2*10**5+10):
    now += point_Start[i]
    now -= point_End[i]
    ans = max(now,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,C = map(int,input().split())
point_Start = [0] * (2*10**5+10)
point_End = [0] * (2*10**5+10)
pointchannel_end = defaultdict(int)
ls = [[0,0,0] for _  in range(N)]

for i in range(N):
    start,end,channel = map(int,input().split())
    ls[i] = [start, end, channel]

for i in range(N):
    start,end,channel = ls[i]
    # 同じチャンネルで、繋げられるものがないか
    if pointchannel_end[(2*start,channel)]:
        point_End[2*start] -= 1
        point_End[2*end] += 1
        pointchannel_end[(2*start,channel)] = 0
    else:
        point_Start[2*start-1] += 1
        point_End[2*end] += 1
    pointchannel_end[(2*end,channel)] = 1

now = 0
ans = 0
for i in range(2*10**5+10):
    now += point_Start[i]
    now -= point_End[i]
    ans = max(now,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,C = map(int,input().split())
point_Start = [0] * (2*10**5+10)
point_End = [0] * (2*10**5+10)
pointchannel_end = defaultdict(int)
ls = [[0,0,0] for _  in range(N)]

for i in range(N):
    start,end,channel = map(int,input().split())
    ls[i] = [start, end, channel]

for i in range(N):
    start,end,channel = ls[i]
    # 同じチャンネルで、繋げられるものがないか
    if pointchannel_end[(2*start,channel)]:
        point_End[2*start] -= 1
        point_End[2*end] += 1
    else:
        point_Start[2*start-1] += 1
        point_End[2*end] += 1
    pointchannel_end[(2*end,channel)] = 1

now = 0
ans = 0
for i in range(2*10**5+10):
    now += point_Start[i]
    now -= point_End[i]
    ans = max(now,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,C = map(int,input().split())
point_Start = [0] * (2*10**5+10)
point_End = [0] * (2*10**5+10)
pointchannel_end = defaultdict(int)
ls = [[0,0,0] for _  in range(N)]

for i in range(N):
    start,end,channel = map(int,input().split())
    ls[i] = [start, end, channel]

for i in range(N):
    start,end,channel = ls[i]
    # 同じチャンネルで、繋げられるものがないか
    if pointchannel_end[(2*start,channel)]:
        point_End[2*start] -= 1
        point_End[2*end] += 1
    else:
        point_Start[2*start-1] += 1
        point_End[2*end] += 1
        pointchannel_end[(2*end,channel)] = 1

now = 0
ans = 0
for i in range(2*10**5+10):
    now += point_Start[i]
    now -= point_End[i]
    ans = max(now,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = list(map(int,input().split()))
T = [0]*(10**5+2)
S = [0]*(10**5+2)
for i in range(N):
    X,Y,_ = list(map(int,input().split()))
    T[X-1] += 1
    T[Y] += -1
for i in range(1,10**5+2):
    S[i]=S[i-1]+T[i-1]
print(max(S))

Submission status: Wrong Answer

Solution code:
import sys
import heapq

input = sys.stdin.readline
N, C = map(int, input().split())
stc = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
hq = []
heapq.heapify(hq)

ans = 0
for s, t, _ in stc:
    while len(hq) > 0 and hq[0][0] < s:
        heapq.heappop(hq)
    ans = max(ans, len(hq) + 1)
    heapq.heappush(hq, (t, s))
print(ans)

Submission status: Wrong Answer

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

ans = 0
use = 0
for i in range(len(v)):
    use += v[i]
    ans = max(use, ans)
print(ans)

Submission status: Wrong Answer

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

ans = 0
use = 0
for i in range(10**5+10):
    use += v[i]
    ans = max(use, ans)
print(ans)

Submission status: Wrong Answer

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

ans = 0
use = 0
for i in range(10**5+1):
    use += v[i]
    ans = max(use, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    n, c = map(int, input().split())
    channels = [[] for _ in range(c)]
    for _ in range(n):
        i, j, k = map(int, input().split())
        channels[k-1].append([i, j])

    programs = []
    for channel in channels:
        if channel == []:
            continue

        for i in range(len(channel)-1):
            if channel[i][1] == channel[i+1][0]:
                channel[i+1][0] = channel[i][0]
            else:
                programs.append(channel[i])
        programs.append(channel[-1])

    programs.sort()

    from heapq import heapify, heappushpop, heappush

    heap = [programs[0][1]]
    heapify(heap)
    for i in range(1, len(programs)):
        if heap[0] < programs[i][0]:
            heappushpop(heap, programs[i][1])
        else:
            heappush(heap, programs[i][1])
    
    print(len(heap))

main()

Submission status: Wrong Answer

Solution code:
from numpy import *
N,C = map(int,input().split())
T = sorted([list(map(int,input().split())) for n in range(N)])
imos = zeros((C,10**5+2),int64)

for s,t,c in T:
  imos[c-1][s]+=1
  imos[c-1][t]-=1

imos = cumsum(imos,axis=0)
imos = cumsum(imos,axis=1)
print(max(imos[-1]))

Submission status: Wrong Answer

Solution code:
from numpy import *
N,C = map(int,input().split())
T = sorted([list(map(int,input().split())) for n in range(N)])
imos = zeros((C,10**5+1),int64)

for s,t,c in T:
  imos[c-1][s-1]+=1
  imos[c-1][t]-=1

imos = cumsum(imos,axis=0)
imos = cumsum(imos,axis=1)
print(max(imos[-1]))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import heapq

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

P = []
for i in range(N):
    s, t, c = map(int, input().split())
    P.append((s, t, c))
P.sort(key=lambda x: x[0])

hq = []
heapq.heapify(hq)  # リストhqのheap化
ans = 0
for i in range(N):
    t = []
    s, t, c = P[i]

    if hq:
        pt, pc = heapq.heappop(hq)
        if pt < s or pt == s and pc == c:
            heapq.heappush(hq, (t, c))
        else:
            heapq.heappush(hq, (pt, pc))
            heapq.heappush(hq, (t, c))
    else:
        heapq.heappush(hq, (t, c))

    ans = max(ans, len(hq))
print(ans)

Submission status: Wrong Answer

Solution code:
import heapq

n, C = map(int, input().split())
stc = []
for i in range(n):
    stc.append(list(map(int, input().split())))
stc.sort()
tel = [[0, 0]]
heapq.heapify(tel)
for i in range(n):
    s, t, c = stc[i][0], stc[i][1], stc[i][2]
    test = heapq.heappop(tel)
    temp = test
    while True:
        if temp[1] == c:
            break
        temp = heapq.heappushpop(tel, temp)
        if temp == test:
            break
    if temp[1] == c:
        if s >= test[0]:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
    else:            
        if s >= test[0] + 1:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
print(len(tel))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,c=map(int,input().split())
prog=[]
video=[0]*(10**5+1)
for i in range(n):
    s,t,ci=tuple(map(int,input().split()))
    video[s-1]+=1
    video[t]-=1
from itertools import accumulate
videoacc=list(accumulate(video))

print(max(videoacc))

Submission status: Wrong Answer

Solution code:
import heapq

n, C = map(int, input().split())
stc = []
for i in range(n):
    stc.append(list(map(int, input().split())))
stc.sort(key = lambda x: x[2])
stc.sort()
tel = [[0, 0]]
heapq.heapify(tel)
for i in range(n):
    s, t, c = stc[i][0], stc[i][1], stc[i][2]
    test = heapq.heappop(tel)
    if test[1] == c:
        if s >= test[0]:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
    else:
        if s >= test[0] + 1:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
print(len(tel))

Submission status: Wrong Answer

Solution code:
import heapq

n, C = map(int, input().split())
stc = []
for i in range(n):
    stc.append(list(map(int, input().split())))
stc.sort()
tel = [[0, 0]]
heapq.heapify(tel)
for i in range(n):
    s, t, c = stc[i][0], stc[i][1], stc[i][2]
    test = heapq.heappop(tel)
    if test[1] == c:
        if s >= test[0]:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
    else:
        if s >= test[0] + 1:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
print(len(tel))

Submission status: Wrong Answer

Solution code:
import heapq

n, C = map(int, input().split())
stc = []
for i in range(n):
    stc.append(list(map(int, input().split())))
stc.sort()
tel = [[0, 0]]
heapq.heapify(tel)
for i in range(n):
    s, t, c = stc[i][0], stc[i][1], stc[i][2]
    test = heapq.heappop(tel)
    if test[1] == c:
        if s >= test[0] + 1:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
    else:
        if s >= test[0] + 1:
            heapq.heappush(tel, [t, c])
        else:
            heapq.heappush(tel, test)
            heapq.heappush(tel, [t, c])
print(len(tel))

Submission status: Wrong Answer

Solution code:
import heapq

n, C = map(int, input().split())
stc = []
for i in range(n):
    stc.append(list(map(int, input().split())))
stc.sort()
c = [0]
heapq.heapify(c)
for i in range(n):
    s, t = stc[i][0], stc[i][1]
    test = heapq.heappop(c)
    if s >= test + 1:
        heapq.heappush(c, t)
    else:
        heapq.heappush(c, test)
        heapq.heappush(c, t)
print(len(c))

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N,C=LI()
  l=[0]*100100

  for _ in range(N):
    s,t,c=LI()
    l[s]+=1
    l[t+1]-=1

  for i in range(100000):
    l[i+1]+=l[i]

  return max(l)

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n, c = map(int, input().split())
stc = [[] for i in range(c+1)]
for i in range(n):
  s_, t_, c_ = map(int, input().split())
  stc[c_].append([s_,t_])
  

stc_ = []
for i in range(1, c+1):
    stc[i] = sorted(stc[i], key=lambda x:(x[0], x[1]))
    j = 0
    l = len(stc[i])
    flg = False
    while j < l:
        if not flg:
            cs, ct = stc[i][j][0], stc[i][j][1]
        if j == l-1:
            stc_.append([cs, ct])
            break
        ns, nt = stc[i][j+1][0], stc[i][j+1][1]
        if ct != ns:
            stc_.append([cs, ct])
        else:
            flg = True
            ct = nt
            if j == l - 2:
                stc_.append([cs, ct])
                break
        j += 1
stc_ = sorted(stc_, key=lambda x:(x[0], x[1]))

m = len(stc_)

cnt = np.zeros(10**5+5, dtype=int)
for i in range(m):
    s, t = stc_[i][0]-1, stc_[i][1]
    cnt[s:t] += 1
print(cnt.max())

Submission status: Wrong Answer

Solution code:
import numpy as np

n, c = map(int, input().split())
stc = [[] for i in range(c+1)]
for i in range(n):
  s_, t_, c_ = map(int, input().split())
  stc[c_].append([s_,t_])
  

stc_ = []
for i in range(1, c+1):
    stc[i] = sorted(stc[i], key=lambda x:(x[0], x[1]))
    j = 0
    l = len(stc[i])
    flg = False
    while j < l:
        if not flg:
            cs, ct = stc[i][j][0], stc[i][j][1]
        if j == l-1:
            stc_.append([cs, ct])
            break
        ns, nt = stc[i][j+1][0], stc[i][j+1][1]
        if ct != ns:
            stc_.append([cs, ct])
        else:
            flg = True
            ct = nt
            if j == l - 2:
                stc_.append([cs, ct])
                break
        j += 1
stc_ = sorted(stc_, key=lambda x:(x[0], x[1]))

m = len(stc_)

cnt = np.zeros(10**5+5, dtype=int)
for i in range(m):
    s, t = stc_[i][0], stc_[i][1]+1
    cnt[s:t] += 1
print(cnt.max())

Submission status: Wrong Answer

Solution code:
A,B=list(map(int,input().split()))
l=[0]*100001
for i in range(A):
   X,Y,Z=list(map(int,input().split()))
   for j in range(X-1,Y):
      l[j]+=1
print(max(l))

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, c = ns()
    l = 10 ** 5
    table = [0 for _ in range(l + 2)]

    for _ in range(n):
        s, t, ci = ns()
        table[s] += 1
        table[t] -= 1

    ans = 0
    tmp = 0
    for ti in table:
        tmp += ti
        ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, c = ns()
    l = 10 ** 5
    table = [0 for _ in range(l + 2)]

    for _ in range(n):
        s, t, ci = ns()
        table[s] += 1
        table[t + 1] -= 1

    ans = 0
    tmp = 0
    for ti in table:
        tmp += ti
        ans = max(ans,tmp)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for _ in range(n):
    s, t, c = tuple(map(int, input().split()))
    if cq[c-1]:
        fs, ft = cq[c-1][-1]
        if ft != s:
            cq[c-1].append([s, t])
        else:
            cq[c-1][-1] = [fs, t]
    else:
        cq[c-1].append([s, t])

R = [0] * (2*10**5+3)
for qq in cq:
    for s, t in qq:
        R[2*s-1] += 1
        R[2*t+2] -= 1

from itertools import accumulate
CR = list(accumulate(R))

print(max(CR))

Submission status: Wrong Answer

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

for _ in range(n):
    s, t, c = tuple(map(int, input().split()))
    if cq[c-1]:
        fs, ft = cq[c-1][-1]
        if ft != s:
            cq[c-1].append([s, t])
        else:
            cq[c-1][-1] = [fs, t]
    else:
        cq[c-1].append([s, t])

R = [0] * (2*10**5+2)
for qq in cq:
    for s, t in qq:
        R[2*s-1] += 1
        R[2*t+1] -= 1

from itertools import accumulate
CR = list(accumulate(R))

print(max(CR))