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:
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
C = [[] for i in range(M)]
for i in range(N):
    l, r, c = MAP()
    c -= 1
    C[c].append((l, r))

# 同チャンネルで連続する区間をまとめる
LR = []
for i in range(M):
    if C[i]:
        C[i].sort()
        LR.append(C[i][0])
        for j in range(1, len(C[i])):
            l1, r1 = C[i][j-1]
            l2, r2 = C[i][j]
            if r1 == l2:
                LR.pop()
                LR.append((l1, r2))
            else:
                LR.append((l2, r2))

# いもす法
MAX = 2 * 10 ** 5
imos = [0] * (MAX+7)
for l, r in LR:
    # 0.5を考慮するため2倍して考える
    l *= 2; r *= 2
    imos[l-1] += 1
    imos[r] -= 1
imos = list(accumulate(imos))
print(max(imos))

Submission status: Wrong Answer

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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
MAX = 2 * 10 ** 5
# いもす法
imos = [0] * (MAX+7)
for i in range(N):
    l, r, _ = MAP()
    # 0.5を考慮するため2倍して考える
    l *= 2; r *= 2
    imos[l-1] += 1
    imos[r] -= 1
imos = list(accumulate(imos))
print(max(imos))

Submission status: Wrong Answer

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

#チャンネルごとにソート
from operator import itemgetter
bangumi=sorted(bangumi, key=itemgetter(2))

nowch=0
syuryo=0
for s,t,c in bangumi:
  if c==nowch and s==syuryo:
    for i in range(s+1,t+1): #時刻Sでの重複数え上げを防ぐ
      jikan[i]+=1
  else:
    for i in range(s,t+1):
      jikan[i]+=1
  nowch=c
  syuryo=t

print(max(jikan))

Submission status: Wrong Answer

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

#チャンネルごとにソート
from operator import itemgetter
bangumi=sorted(bangumi, key=itemgetter(2))

nowch=0
syuryo=0
for s,t,c in bangumi:
  if nowch==c and s==syuryo:
    for i in range(s+1,t+1):
      jikan[i]+=1
  else:
    for i in range(s,t+1):
      jikan[i]+=1
  nowch=c
  syuryo=t

print(max(jikan))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, C = list(map(int, input().split()))
    recording = {i: [] for i in range(C)}
    end = 0
    for i in range(N):
        s, t, c = list(map(int, input().split()))
        recording[c - 1].append((s, t))
        end = max(end, t)

    imos = [[0 for i in range(end + 1)] for j in range(C)]

    for c in range(C):
        for s, t in recording[c]:
            if imos[c][s] != -1:
                imos[c][s - 1] = 1
                imos[c][t] = -1
            elif imos[c][s] == -1:
                imos[c][s] = 0
                imos[c][t] = -1

    for c in range(C):
        for i in range(1, end + 1):
            if imos[c][i - 1] == 1 and imos[c][i] != -1:
                imos[c][i] = 1

    count = 0
    for i in range(end + 1):
        temp = 0
        for c in range(C):
            if imos[c][i] == 1:
                temp += 1
        count = max(count, temp)

    temp=0
    for c in range(C):
        if imos[c][i] == -1:
            temp += 1
    count = max(count, temp)

    print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, C = list(map(int, input().split()))
    recording = {i: [] for i in range(C)}
    end = 0
    for i in range(N):
        s, t, c = list(map(int, input().split()))
        recording[c - 1].append((s, t))
        end = max(end, t)

    imos = [[0 for i in range(end + 1)] for j in range(C)]
    for c in range(C):
        for s, t in recording[c]:
            if imos[c][s] != -1:
                imos[c][s - 1] = 1
                imos[c][t] = -1
            elif imos[c][s] == -1:
                imos[c][s] = 0
                imos[c][t] = -1

    for c in range(C):
        for i in range(1, end + 1):
            if imos[c][i - 1] == 1 and imos[c][i] != -1:
                imos[c][i] = 1

    count = 0
    for i in range(end + 1):
        temp = 0
        for c in range(C):
            if imos[c][i] == 1:
                temp += 1
        count = max(count, temp)
    print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, C = list(map(int, input().split()))
    recording = {i: [] for i in range(C)}
    end = 0
    for i in range(N):
        s, t, c = list(map(int, input().split()))
        recording[c - 1].append((s, t))
        end = max(end, t)

    imos = [[0 for i in range(end + 1)] for j in range(C)]
    for c in range(C):
        for s, t in recording[c]:
            if imos[c][s] != -1:
                imos[c][s - 1] = 1
                imos[c][t] = -1
            elif imos[c][s] == -1:
                imos[c][s] = 0
                imos[c][t] = -1

    for c in range(C):
        for i in range(1, end + 1):
            if imos[c][i - 1] == 1 and imos[c][i] != -1:
                imos[c][i] = 1

    count = 0

    for i in range(1, end + 1):
        temp = 0
        for c in range(C):
            if imos[c][i] == 1:
                temp += 1
        count = max(count, temp)

    print(count)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    N,C=list(map(int,input().split()))
    recording={i:[] for i in range(C)}
    end=0
    for i in range(N):
        s,t,c=list(map(int,input().split()))
        recording[c-1].append((s,t))
        end=max(end,t)

    imos=[[0 for i in range(end*2+2)] for j in range(C)]
    for c in range(C):
        for s,t in recording[c]:
            s*=2
            t*=2
            if imos[c][s]!=-1:
                imos[c][s-1]=1
                imos[c][t]=-1
            elif imos[c][s]==-1:
                imos[c][s]=0
                imos[c][t]=-1

    for c in range(C):
        for i in range(1,(end+1)*2):
            if imos[c][i-1]==1 and imos[c][i]!=-1:
                imos[c][i]=1

    count=0

    for i in range(1,(end+1)*2):
        temp=0
        for c in range(C):
            if imos[c][i]==1:
                temp+=1
        count=max(count,temp)

    print(count)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    N,C=list(map(int,input().split()))
    recording={i:[] for i in range(C)}
    end=0
    for i in range(N):
        s,t,c=list(map(int,input().split()))
        recording[c-1].append((s,t))
        end=max(end,t)

    imos=[[0 for i in range(end*2+2)] for j in range(C)]
    for c in range(C):
        for s,t in recording[c]:
            s*=2
            t*=2
            if imos[c][s]!=-1:
                imos[c][s-1]=1
                imos[c][t]=-1
            elif imos[c][s]==-1:
                imos[c][s]=0
                imos[c][t]=-1

    for c in range(C):
        for i in range(1,(end+1)*2):
            if imos[c][i-1]==1 and imos[c][i]!=-1:
                imos[c][i]=1

    count=0

    for i in range(1,(end+1)*2):
        temp=0
        for c in range(C):
            if imos[c][i]==1:
                temp+=1
        count=max(count,temp)

    print(count)
    for i in imos:
        print(i)

Submission status: Wrong Answer

Solution code:


if __name__ == '__main__':
    N,C=list(map(int,input().split()))
    recording={i:[] for i in range(C)}
    end=0
    for i in range(N):
        s,t,c=list(map(int,input().split()))
        recording[c-1].append((s,t))
        end=max(end,t)

    imos=[[0 for i in range(end+1)] for j in range(C)]
    for c in range(C):
        for s,t in recording[c]:
            if imos[c][s]!=-1:
                imos[c][s-1]=1
                imos[c][t]=-1
            elif imos[c][s]==-1:
                imos[c][s]=0
                imos[c][t]=-1

    for c in range(C):
        for i in range(1,end+1):
            if imos[c][i-1]==1 and imos[c][i]!=-1:
                imos[c][i]=1

    count=0

    for i in range(1,end+1):
        temp=0
        for c in range(C):
            if imos[c][i]==1:
                temp+=1
        count=max(count,temp)

    print(count)
    for i in imos:
        print(i)

Submission status: Wrong Answer

Solution code:


if __name__ == '__main__':
    N,C=list(map(int,input().split()))
    recording={i:[] for i in range(C)}
    end=0
    for i in range(N):
        s,t,c=list(map(int,input().split()))
        recording[c-1].append((s,t))
        end=max(end,t)

    imos=[[0 for i in range(end+1)] for j in range(C)]
    for c in range(C):
        for s,t in recording[c]:
            imos[c][s-1]=1
            imos[c][t]=-1

    for c in range(C):
        for i in range(1,end+1):
            if imos[c][i-1]==1 and imos[c][i]!=-1:
                imos[c][i]=1

    count=0

    for i in range(1,end+1):
        temp=0
        for c in range(C):
            if imos[c][i]==1:
                temp+=1
        count=max(count,temp)

    print(count)
    for i in imos:
        print(i)

Submission status: Wrong Answer

Solution code:


if __name__ == '__main__':
    N,C=list(map(int,input().split()))
    recording={i:[] for i in range(C)}
    end=0
    for i in range(N):
        s,t,c=list(map(int,input().split()))
        recording[c-1].append((s,t))
        end=max(end,t)
    for c in range(C):
        recording[c].sort(key=lambda x:x[0])
    using={i:[] for i in range(C)}
    for c in range(C):
        channel=recording[c]
        if len(recording[c])==0:
            continue
        elif len(channel)==1:
            using[c].append((channel[0][0],channel[0][1]))
        else:
            start = recording[c][0][0]
            for i in range(len(recording[c])-1):
                if channel[i][1]!=channel[i+1][0]:
                    using[c].append((start,channel[i][1]))
                    start=channel[i+1][0]
    count=0
    imos=[ [0 for i in range(end+1)] for j in range(C)]
    for c in range(C):
        for s,t in using[c]:
            imos[c][s]=1
            imos[c][t]=-1
    for c in range(C):
        for i in range(1,end+1):
            if imos[c][i-1]==1 and imos[c][i]!=-1:
                imos[c][i]=1
    count=0
    for i in range(1,end+1):
        temp=0
        for c in range(C):
            if imos[c][i]==1:
                temp+=1
        count=max(count,temp)

    print(count)

Submission status: Wrong Answer

Solution code:


if __name__ == '__main__':
    N,C=list(map(int,input().split()))
    recording={i:[] for i in range(C)}
    end=0
    for i in range(N):
        s,t,c=list(map(int,input().split()))
        recording[c-1].append((s,t))
        end=max(end,t)
    for c in range(C):
        recording[c].sort(key=lambda x:x[0])
    using={i:[] for i in range(C)}
    for c in range(C):
        channel=recording[c]
        if len(recording[c])==0:
            continue
        elif len(channel)==1:
            using[c].append((channel[0][0]-0.5,channel[0][1]))
        else:
            start = recording[c][0][0] - 0.5
            for i in range(len(recording[c])-1):
                if channel[i][1]!=channel[i+1][0]:
                    using[c].append((start,channel[i][1]))
                    start=channel[i+1][0]-0.5
    count=0

    for t in range(1,end):
        temp=0
        for c in range(C):
            for used in using[c]:
                if used[0]<=t<used[1]:
                    temp+=1
        count=max(count,temp)

    print(count)

Submission status: Wrong Answer

Solution code:
from collections import deque


n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort(key=lambda x:x[0])
c=1
q=deque([stc[0]])

for i in range(1,n):
    q.append(stc[i])
    if q[-1][2]==q[0][2]:
        if q[-1][0]>=q[0][1]:
            q.popleft()
    else:
        if q[-1][0]-1>=q[0][1]:
            q.popleft()
    c=max(c,len(q))

print(c)

Submission status: Wrong Answer

Solution code:
from collections import deque


n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
#for i in range(n):
#    stc[i][0]-=1
stc.sort(key=lambda x:x[1])
c=1
q=deque([stc[0]])
for i in range(1,n):
    q.append(stc[i])
    if q[-1][2]==q[0][2]:
        if q[-1][0]>=q[0][1]:
            q.popleft()
    else:
        if q[-1][0]-1>=q[0][1]:
            q.popleft()
    c=max(c,len(q))

print(c)

Submission status: Wrong Answer

Solution code:
from collections import deque


n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    stc[i][0]-=1
stc.sort(key=lambda x:x[1])
c=1
q=deque([stc[0]])
for i in range(1,n):
    q.append(stc[i])
    if q[-1][0]>=q[0][1]:
        q.popleft()
    c=max(c,len(q))

print(c)

Submission status: Wrong Answer

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

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

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


for i in range(C):
    for j in range(1, x):
        imos[i][j] += imos[i][j - 1]

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import heapq

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

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

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

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

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

program.sort()

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

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

print(len(recorder))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# D - Recording

N, C = map(int, input().split())
gantt = [0] * (10**5 + 1)

for _ in range(N):
    s, t, c = map(int, input().split())
    gantt[s] += 1
    if t+1 < len(gantt):
        gantt[t+1] -= 1
        
for idx in range(1, len(gantt)):
    gantt[idx] += gantt[idx-1]
    
print(max(gantt))

Submission status: Wrong Answer

Solution code:
# D - Recording

N, C = map(int, input().split())
gantt = [0] * (10**5 + 1)

for _ in range(N):
    s, t, c = map(int, input().split())
    gantt[s] += 1
    if t+1 < len(gantt):
        gantt[t+1] -= 1
        
for idx in range(len(gantt)-1):
    gantt[idx+1] += gantt[idx]
    
print(max(gantt))

Submission status: Wrong Answer

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

E = sorted(E, key=lambda x:-x[2])
E = sorted(E, key=lambda x:x[0])
 
n = 0
nmax = 0
ie = 0
X = [0]*31
while ie<len(E):
    t = E[ie][0]
    on  = []
    off = []
    while ie<len(E) and E[ie][0]==t and E[ie][2]==1:
        c = E[ie][1]
        if X[c]==0: n+=1
        X[c] +=1
        ie+=1

    nmax = max(nmax, n)
        
    while ie<len(E) and E[ie][0]==t and E[ie][2]==-1:
        X[E[ie][1]] -= 1
        n-=1
        ie+=1

print(nmax)

Submission status: Wrong Answer

Solution code:
from itertools import *
from operator import *

def main():
	n, c, *L = map(int, open(0).read().split())
	a = [0] * (10 ** 5 + 1)
	bef = (0, 0)
	for s, t, c in sorted(zip(*[iter(L)] * 3), key=itemgetter(2)):
		a[s - 1 + (bef==(c, s))] += 1
		a[t] -= 1
		bef = (c, t)
	print(max(accumulate(a)))

if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n,c,*L=map(int,open(0).read().split())
a=[0]*(max(L[1::3])+1)
for s,t,_ in zip(*[iter(L)]*3):
	a[s-1]+=1
	a[t]-=1
print(max(accumulate(a)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, C = map(int, input().split(' '))
lim = (10**5+2)*2
buf = [0 for _ in range(lim)]

for _ in range(N):
    s, t, c = map(int, input().split(' '))
    buf[s*2-1] += 1
    buf[t*2] -= 1

ans = 0
for i in range(1, lim):
    buf[i] += buf[i-1]
    ans = max(ans, buf[i])

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, C = map(int, input().split(' '))
lim = (10**5+2)*2
buf = [0 for _ in range(lim)]

for _ in range(N):
    s, t, c = map(int, input().split(' '))
    buf[s*2-1] += 1
    buf[t*2+1] -= 1

ans = 0
for i in range(1, lim):
    buf[i] += buf[i-1]
    ans = max(ans, buf[i])

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, C = map(int, input().split(' '))
lim = (10**5+1)*2
buf = [0 for _ in range(lim)]

for _ in range(N):
    s, t, c = map(int, input().split(' '))
    buf[s*2-1] += 1
    buf[t*2+1] -= 1

ans = 0
for i in range(1, lim):
    buf[i] += buf[i-1]
    ans = max(ans, buf[i])

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7




def main():
    n, c = map(int, input().split())
    stk = [list(map(int, input().split())) for i in range(n)]
    stk = sorted(stk,key=lambda x:x[0])

    ans = 1
    l = []
    heapify(l)
    heappush(l,stk[0][1]-0.0000001)
    for i in range(1, n):
        ll = []
        size = len(l)
        for j in range(size):
            v = heappop(l)
            if stk[i][0] - 0.5 < v :
                ll.append(v)
        for j in range(len(ll)):
            heappush(l, ll[j])
        
        heappush(l, stk[i][1]-0.0000001)
        ans = max(ans , len(l))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7




def main():
    n, c = map(int, input().split())
    stk = [list(map(int, input().split())) for i in range(n)]
    stk = sorted(stk,key=lambda x:x[0])

    ans = 1
    l = []
    heapify(l)
    heappush(l,stk[0][1])
    for i in range(1, n):
        ll = []
        size = len(l)
        for j in range(size):
            v = heappop(l)
            if stk[i][0] >= v + 0.5:
                pass
            else:
                ll.append(v)
        for j in range(len(ll)):
            heappush(l, ll[j])
        
        heappush(l, stk[i][1])
        ans = max(ans , len(l))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7




def main():
    n, c = map(int, input().split())
    stk = [list(map(int, input().split())) for i in range(n)]
    stk = sorted(stk)

    ans = 1
    l = []
    heapify(l)
    heappush(l,stk[0][1])
    for i in range(1, n):
        ll = []
        for j in range(len(l)):
            v = heappop(l)
            if stk[i][0] >= v + 0.5:
                pass
            else:
                ll.append(v)
        for j in range(len(ll)):
            heappush(l, ll[j])
        
        heappush(l, stk[i][1])
        ans = max(ans , len(l))
    print(ans)


    
    



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def main():
    n, c = map(int, input().split())
    stk = [list(map(int, input().split())) for i in range(n)]
    stk = sorted(stk)

    ans = 1
    l = []
    heapify(l)
    heappush(l,stk[0][1])
    for i in range(1, n):
        ll = []
        for j in range(len(l)):
            v = heappop(l)
            if stk[i][0] > v + 0.5:
                pass
            else:
                ll.append(v)
        for j in range(len(ll)):
            heappush(l, ll[j])
        
        heappush(l, stk[i][1])
        ans = max(ans , len(l))
    print(ans)


    
    



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[s-1] += 1
    imos[t] -= 1

ans = 0
a = 0
for i in imos:
    a += i
    ans = max(ans, a)

print(ans)

Submission status: Wrong Answer

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

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  
  min_idx = None
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] <= tmp_stc_r:
      if min_idx is None: min_idx = j
      else:
        if rs[j][0] < rs[min_idx][0]: min_idx = j

  if min_idx is None: rs.append([STC[i][1], STC[i][2]])
  else: rs[j] = [STC[i][1], STC[i][2]]
  
  rs.sort()
print(len(rs))

Submission status: Wrong Answer

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

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] < tmp_stc_r:
      rs[j] = [STC[i][1], STC[i][2]]
      break
    else:
      rs.append([STC[i][1], STC[i][2]])
      break
  rs.sort()
print(len(rs))

Submission status: Wrong Answer

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

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] <= tmp_stc_r:
      rs[j] = [STC[i][1], STC[i][2]]
      break
    else:
      rs.append([STC[i][1], STC[i][2]])
      break
  rs.sort()
print(len(rs))

Submission status: Wrong Answer

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

rs = [STC[0][1]]
for i in range(1,N):
  len_rs = len(rs)
  for j in range(len_rs):
    if rs[j] <= STC[i][0]:
      rs[j] = STC[i][1]
      break
    else:
      rs.append(STC[i][1])
      break
  rs.sort()
print(len(rs))

Submission status: Wrong Answer

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

rs = [STC[0][1]]
for i in range(1,N):
  len_rs = len(rs)
  for j in range(len_rs):
    if rs[j] <= STC[i][0]:
      rs[j] = STC[i][1]
      break
    else:
      rs.append(STC[i][1])
      break
print(len(rs))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]
stc.sort(key=itemgetter(2, 0))

cs = [0] * (10 ** 5 * 2 + 1)
pt = -1
for s, t, c in stc:
    if pt == s:
        cs[s * 2] += 1
    else:
        cs[s * 2 - 1] += 1
    cs[t * 2] -= 1
    pt = t

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

print(max(cs))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]
stc.sort(key=itemgetter(2, 0))

cs = [0] * (10 ** 5 * 2 + 1)
pt = -1
for s, t, c in stc:
    if pt == s:
        cs[s * 2] += 1
    else:
        cs[s * 2 - 1] += 1
    cs[t * 2] -= 1
    t = pt

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

print(max(cs))

Submission status: Wrong Answer

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

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

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

print(max(cs))

Submission status: Wrong Answer

Solution code:
import sys

N,C=map(int, sys.stdin.readline().split()) 
stc=[ map(int, sys.stdin.readline().split()) for _ in range(N)]
max_t=max(stc, key=(lambda x: x[1]))[1]

L=[ 0 for _ in range(max_t+1) ]

for s,t,c in stc:
    for i in range(s,t+1):
        L[i]+=1

print max(L)-1

Submission status: Wrong Answer

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

N,C=map(int, sys.stdin.readline().split()) 
stc=[ map(int, sys.stdin.readline().split()) for _ in range(N)]
max_t=max(stc, key=(lambda x: x[1]))[1]

L=[ 0 for _ in range(max_t+1) ]

for s,t,c in stc:
    for i in range(s,t+1):
        L[i]+=1

print max(L)

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
pairs = zip(S, T)
sortedpairs = sorted(pairs, key=lambda x: x[1])
sortedpairs = sorted(sortedpairs, key=lambda x: x[0])
for i in range(N):
    S[i] = sortedpairs[i][0]
    T[i] = sortedpairs[i][1]

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)
#print(timeC)

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
pairs = zip(S, T)
sortedpairs = sorted(pairs, key=lambda x: x[0])
for i in range(N):
    S[i] = sortedpairs[i][0]
    T[i] = sortedpairs[i][1]

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, a = LI()
    S[i],T[i] = s, t
    c[i] = a
    if maxt<t:
        maxt = t
pairs = zip(S, T)
sortedpairs = sorted(pairs, key=lambda x: x[0])
for i in range(N):
    S[i] = sortedpairs[i][0]
    T[i] = sortedpairs[i][1]


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)