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 getter(starts, ends):
    while starts:
        if starts[-1][0] <= ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(C, targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = [0]*(C+1)
    for x, p in getter(starts, ends):
        if p:
            active[x[2]] += 1
        else:
            active[x[2]] -= 1
        result = max(result, sum(active))
    return result


if __name__ == "__main__":
    n, C  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s-1, t, c))
    print(foo(C, targets))

Submission status: Wrong Answer

Solution code:

def getter(starts, ends):
    while starts:
        if starts[-1][0] < ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(C, targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = [0]*(C+1)
    for x, p in getter(starts, ends):
        if p:
            active[x[2]] += 1
        else:
            active[x[2]] -= 1
        result = max(result, sum(active))
    return result


if __name__ == "__main__":
    n, C  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s-1, t, c))
    print(foo(C, targets))

Submission status: Wrong Answer

Solution code:



def getter(starts, ends):
    while starts:
        if starts[-1][0] < ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = set()
    for x, p in getter(starts, ends):
        if p:
            active.add(x)
        else:
            active.remove(x)
        result = max(result, len(active))
    return result


if __name__ == "__main__":
    n,c  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s-1, t, c))
    print(foo(targets))

Submission status: Wrong Answer

Solution code:
def getter(starts, ends):
    while starts:
        if starts[-1][0] <= ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = set()
    for x, p in getter(starts, ends):
        if p:
            active.add(x)
        else:
            active.remove(x)
        result = max(result, len(active))
    return result


if __name__ == "__main__":
    n,c  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s, t, c))
    print(foo(targets))

Submission status: Wrong Answer

Solution code:


def foo(n, c, targets):
    timeline = {}
    for s, t, c in targets:
        for i in range(s-1, t):
            xs = timeline.get(i, None)
            if xs is None:
                xs = []
            xs.append(c)
            timeline[i] = xs
    return max([len(v) for k, v in timeline.items()])




if __name__ == "__main__":
    n,c  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s,t,c))
        
    print(foo(n, c, targets))

Submission status: Wrong Answer

Solution code:

def foo(n, c, targets):
    timeline = {}
    for s, t, c in targets:
        for i in range(s, t+1):
            xs = timeline.get(i, None)
            if xs is None:
                xs = []
            xs.append(c)
            timeline[i] = xs
    return max([len(v) for k, v in timeline.items()])




if __name__ == "__main__":
    n,c  = map(int, input().split())

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s,t,c))
        
    print(foo(n, c, targets))

Submission status: Wrong Answer

Solution code:
temp_in=input()
temp_in=temp_in.split(" ")
temp_in=list(map(int,temp_in))
a,b=temp_in
times=[0]*(10**5+2)
times_sum=[0]*(10**5+2)
for i in range(a):
    temp_in=input()
    temp_in=temp_in.split(" ")
    temp_in=list(map(int,temp_in))
    times[temp_in[0]]+=1
    times[temp_in[1]+1]-=1
times_sum[0]=times[0]
for i in range(1,len(times_sum)):
    times_sum[i]+=times_sum[i-1]+times[i]
print(max(times_sum))

Submission status: Wrong Answer

Solution code:
temp_in=input()
temp_in=temp_in.split(" ")
temp_in=list(map(int,temp_in))
a,b=temp_in
times=[0]*(10**5+2)
times_sum=[0]*(10**5+2)
for i in range(a):
    temp_in=input()
    temp_in=temp_in.split(" ")
    temp_in=list(map(int,temp_in))
    times[temp_in[0]]+=1
    times[temp_in[1]+1]-=1
for i in range(len(times_sum)-1):
    times_sum[i]+=times_sum[i-1]+times[i]
print(max(times_sum))

Submission status: Wrong Answer

Solution code:
class Fenwick:
    def __init__(self, N):
        self.fen = [0 for _ in range(N + 1)]

    def add(self, idx, val):
        while idx < len(self.fen):
            self.fen[idx] += val
            idx += idx & (-idx)

    def accum(self, idx):
        ret = 0
        while idx > 0:
            ret += self.fen[idx]
            idx -= idx & (-idx)
        return ret


def main():
    N, C = map(int, input().split())
    stc = [list(map(int, input().split())) for _ in range(N)]
    # print(stc)
    stc.sort(key=lambda x: x[0])
    stc.sort(key=lambda x: x[2])
    i = 0
    while i + 1 < len(stc):
        if stc[i][2] == stc[i + 1][2] and stc[i][1] == stc[i + 1][0]:
            stc[i] = (stc[i][0], stc[i + 1][1], stc[i][2])
            del(stc[i + 1])
        i += 1
    # print(stc)

    fen = Fenwick(10 ** 5)
    for (s, t, c) in stc:
        fen.add(max(1, s - 1), 1)
        fen.add(t, -1)

    cnt = [fen.accum(i) for i in range(10 ** 5 + 1)]
    # print(cnt[:20])

    x = max(cnt)
    print(x)


main()

Submission status: Wrong Answer

Solution code:
class Fenwick:
    def __init__(self, N):
        self.fen = [0 for _ in range(N + 1)]

    def add(self, idx, val):
        while idx < len(self.fen):
            self.fen[idx] += val
            idx += idx & (-idx)

    def accum(self, idx):
        ret = 0
        while idx > 0:
            ret += self.fen[idx]
            idx -= idx & (-idx)
        return ret


def main():
    N, C = map(int, input().split())
    stc = [list(map(int, input().split())) for _ in range(N)]
    # print(stc)
    stc.sort(key=lambda x: x[0])
    stc.sort(key=lambda x: x[2])
    i = 0
    while i < len(stc):
        if i + 1 < len(stc) and stc[i][2] == stc[i + 1][2] and stc[i][1] == stc[i + 1][0]:
            stc[i] = (stc[i][0], stc[i + 1][1], stc[i][2])
            del(stc[i + 1])
        i += 1
    # print(stc)

    fen = Fenwick(10 ** 5)
    for (s, t, c) in stc:
        fen.add(max(1, s), 1)
        fen.add(t + 1, -1)

    cnt = [fen.accum(i) for i in range(10 ** 5 + 1)]
    # print(cnt[:20])

    x = max(cnt)
    print(x)


main()

Submission status: Wrong Answer

Solution code:
from operator  import itemgetter 

"""
def is_overlap(list_i,list_j):
    if list_j[1]<=list_i[0] and list_i[0] <= list_j[1] and list_j[1] <= list_j[1]:
        return True
    elif list_i[0] <= list_j[0] and list_j[0] <= list_i[1] and list_i[0] <= list_j[1] and list_j[1] <= list_i[1]:
        return True
    elif list_i[0]<=list_j[0] and list_j[0] <= list_i[1] and list_i[1] <= list_j[1]:
        return True
    
    return False
"""
"""
ようはかぶった時に，別のレコーダーを用意すればいい話
"""

#録画の終了時間と，　新規録画番組の開始時間を比較，　被っていないならばTRUEを返す
def is_not_overlap(list_i, list_j):
    if list_i[2] == list_j[2]:
        if list_i[1] <= list_j[0]:
            return True
    else:
        if list_i[1] <= list_j[0]-0.5:
            return True
    

Number_Channel = list(map(int, input().split()))
program_list = []
recorder = []

for _ in range(Number_Channel[0]):
    program_list.append(list(map(int, input().split())))

#番組表を開始時間でソート
program_list.sort(key=itemgetter(0))

#一番早い番組のリストをrecorder1に代入
recorder.append(program_list.pop(0))

for _ in range(len(program_list)):
    
    for i, recorded in enumerate(recorder):
        if is_not_overlap(recorded, program_list[0]):
            recorder[i] = program_list.pop(0)
            break
        else:
            recorder.append(program_list.pop(0))
            break
    

print(len(recorder))

Submission status: Wrong Answer

Solution code:
MAX_T = int(1e5)
N, C = map(int, input().split())
s, t, c = [], [], []
for i in range(N):
    _s, _t, _c = map(int, input().split())
    s.append(_s)
    t.append(_t)
    c.append(_c-1)

upsC = [[0] * (MAX_T + 1) for i in range(C)]
downsC = [[0] * (MAX_T + 1) for i in range(C)]
for i in range(N):
    upsC[c[i]][s[i]] += 1
    downsC[c[i]][t[i]] += 1

ups = [0] * (MAX_T + 1)
downs = [0] * (MAX_T + 1)
for i in range(MAX_T):
    ups[i] = sum([upsC[j][i] for j in range(C)])
    downs[i] = sum([downsC[j][i] for j in range(C)])

ans = 0
cur = 0
for i in range(MAX_T+1):
    cur += ups[i]
    ans = max((ans, cur))
    cur -= downs[i]

print(ans)

Submission status: Wrong Answer

Solution code:
MAX_T = int(1e5)
N, C = map(int, input().split())
s, t, c = [], [], []
for i in range(N):
    _s, _t, _c = map(int, input().split())
    s.append(_s)
    t.append(_t)
    c.append(_c-1)

upsC = [[0] * (MAX_T + 1) for i in range(C)]
downsC = [[0] * (MAX_T + 1) for i in range(C)]
for i in range(N):
    upsC[c[i]][s[i]] += 1
    downsC[c[i]][t[i]] += 1

ups = [0] * (MAX_T + 1)
downs = [0] * (MAX_T + 1)
for i in range(MAX_T):
    ups[i] = sum([upsC[j][i] for j in range(C)])
    downs[i] = sum([downsC[j][i] for j in range(C)])

ans = 0
cur = 0
for i in range(MAX_T):
    cur += ups[i]
    ans = max((ans, cur))
    cur -= downs[i]

print(ans)

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

#チャンネル見る必要がある
#同じチャンネルで連続しているものはくっつける
la = [[[], []] for i in range(c)]
for i in l:
    la[i[2] - 1][0].append(i[0])
    la[i[2] - 1][1].append(i[1])

starts = []
ends = []
for s, e in la:
    wa = set(s).union(set(e))
    seki = set(s).intersection(set(e))
    a = list(wa.difference(seki))
    a.sort()
    for i, j in zip(a[0::2], a[1::2]):
        starts.append(i)
        ends.append(j)

s = min(starts)
e = max(ends)

imos = [0 for i in range(s,e + 1)]
for i, j in zip(starts, ends):
    imos[i - s] += 1
    imos[j - s] -= 1
for i in range(len(imos) - 1):
    imos[i + 1] += imos[i]

print(max(imos))

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

#チャンネル見る必要がある
#→先にくっつける imos法で
la = [[[], []] for i in range(c)]
for i in l:
    la[i[2] - 1][0].append(i[0])
    la[i[2] - 1][1].append(i[1])
l = []
for s, e in la:
    wa = set(s).union(set(e))
    seki = set(s).intersection(set(e))
    a = list(wa.difference(seki))
    a.sort()
    for i, j in zip(a[0::2], a[1::2]):
        l.append([i, j])

#l.sort(key=lambda x: x[0])
l.sort(key=lambda x: x[1])
ans = []
for i in l:
    final = 0
    for ind, j in enumerate(ans):
        if j[1] < i[0]:
            ans[ind][0] = i[0]
            ans[ind][1] = i[1]
            final = 1
            break
    if final == 0:
        ans.append([i[0], i[1]])
print(len(ans))

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

#チャンネル見る必要がある

l.sort(key=lambda x: x[0])
l.sort(key=lambda x: x[1])
ans = []
for i in l:
    final = 0
    for ind, j in enumerate(ans):
        if j[1] < i[0] or (j[1] == i[0] and j[2] == i[2]):
            ans[ind][0] = i[0]
            ans[ind][1] = i[1]
            ans[ind][2] = i[2]
            final = 1
            break
    if final == 0:
        ans.append([i[0], i[1], i[2]])
print(len(ans))

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())
#l.sort(key=lambda x: x[0])
l.sort(key=lambda x: x[1])

#チャンネル見る必要がある...

ans = []
for i in l:
    final = 0
    for ind, j in enumerate(ans):
        if j[1] < i[0] or (j[1] == i[0] and j[2] == i[2]):
            ans[ind][0] = i[0]
            ans[ind][1] = i[1]
            ans[ind][2] = i[2]
            final = 1
            break
    if final == 0:
        ans.append([i[0], i[1], i[2]])
print(len(ans))

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())
l.sort(key=lambda x: x[0])
l.sort(key=lambda x: x[1])

ans = []
for i in l:
    final = 0
    for ind, j in enumerate(ans):
        if j[1] < i[0]:
            ans[ind][0] = i[0]
            ans[ind][1] = i[1]
            final = 1
            break
    if final == 0:
        ans.append([i[0], i[1]])
print(len(ans))

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

l.sort(key=lambda x: x[1])

ans = []
for i in l:
    final = 0
    for ind, j in enumerate(ans):
        if j[1] < i[0]:
            ans[ind][0] = i[0]
            ans[ind][1] = i[1]
            final = 1
            break
    if final == 0:
        ans.append([i[0], i[1]])
print(len(ans))

Submission status: Wrong Answer

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,c]=i2()
b=[0 for i in range(2*10**5+1)]
for i in range(n):
 a=i2()
 b[a[0]*2-1]+=1
 b[a[1]*2]-=1
for i in range(1,2*10**5+1):
 b[i]+=b[i-1]

print(max(b))

Submission status: Wrong Answer

Solution code:
[N, C] = [int(x) for x in input().split(' ')]

st = [[] for i in range(C)]

for i in range(N):
    xs = [int(x) for x in input().split(' ')]
    st[xs[2]-1].append([xs[0], 0])
    st[xs[2]-1].append([xs[1], 1])

for i in range(C):
    xs = sorted(st[i], key=lambda x: x[0])
    st[i] = xs[:1]

    for j in range(len(xs) - 1):
        if (xs[j][1] == 1) and (xs[j+1][1] == 0) and (xs[j][0] == xs[j+1][0]):
            st[i].pop(-1)
        else:
            st[i].append(xs[j+1])

st = sum(st, [])

for i in range(len(st)):
    if st[i][1] == 0:
        st[i][0] -= 0.5


counter = 0
max_counter = 0

st1 = sorted(st, key=lambda x: x[1])
st = sorted(st1, key=lambda x: x[0])

for x in st:
    if x[1] == 0:
        counter += 1
        if counter > max_counter:
            max_counter = counter
    else:
        counter -= 1

print(max_counter)

Submission status: Wrong Answer

Solution code:
[N, X] = [int(x) for x in input().split(' ')]

st = []

for i in range(N):
    xs = [int(x) for x in input().split(' ')]
    st.append((xs[0] - 0.5, 0))
    st.append((xs[1], 1))

counter = 0
max_counter = 0

st1 = sorted(st, key=lambda x: x[1])
st = sorted(st1, key=lambda x: x[0])

for x in st:
    if x[1] == 0:
        counter += 1
        if counter > max_counter:
            max_counter = counter
    else:
        counter -= 1

print(max_counter)

Submission status: Wrong Answer

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

f = [[0] * 100000 for _ in range(C)]

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

for c in range(C):
    for i in range(100000):
        if i > 0:
            f[c][i] += f[c][i-1]

print(max(map(sum, zip(*f))))

Submission status: Wrong Answer

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

f = [[0] * 100000 for _ in range(C)]

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

for c in range(C):
    for i in range(100000):
        if i > 0:
            f[c][i] += f[c][i-1]

p = [0] * 100000
for i in range(100000):
    for c in range(C):
        p[i] += f[c][i]

print(max(p))

Submission status: Wrong Answer

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

f = [[0] * 100000 for _ in range(C)]

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

for c in range(C):
    for i in range(100000):
        if i > 0:
            f[c][i] += f[c][i-1]

p = [0] * 100000
for i in range(100000):
    for c in range(C):
        p[i] += f[c][i]

rec_max = max(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
N,C=map(int,raw_input().split())
a=collections.defaultdict(list)

max_t=0
for i in range(N):
	s,t,c=map(int,raw_input().split())
	a[c].append((s,t))
	max_t=max(max_t,t)

[a[i].sort() for i in a.keys()]
#print a
#print max_t

b=collections.defaultdict(list)


for i,j in a.items():
	start=0
	end=0
	for k in j:
		if start==0 and end==0:
			start=k[0]-1
			#start=k[0]
			end=k[1]
			continue
		elif k[0]<=end:
			end=k[1]
		else:
			b[i].append((start,end))
			start=k[0]-1
			end=k[1]
	else:
		b[i].append((start,end))			

#print "# b"
#print b

c=[0 for i in range(max_t+2)]

for i in b.values():
	for j,k in i:
		#print j,k
		c[j]+=1
		c[k+1]-=1
		#print c
#print c

ans=0
sum=0
for i in c:
	sum+=i
	ans=max(ans,sum)

print ans

Submission status: Wrong Answer

Solution code:
import collections
N,C=map(int,raw_input().split())
a=collections.defaultdict(list)

max_t=0
for i in range(N):
	s,t,c=map(int,raw_input().split())
	a[c].append((s,t))
	max_t=max(max_t,t)

[a[i].sort() for i in a.keys()]
#print a
#print max_t

b=collections.defaultdict(list)


for i,j in a.items():
	start=0
	end=0
	for k in j:
		if start==0 and end==0:
			#start=k[0]-1
			start=k[0]
			end=k[1]
			continue
		elif k[0]<=end:
			end=k[1]
		else:
			b[i].append((start,end))
			start=k[0]-1
			end=k[1]
	else:
		b[i].append((start,end))			

#print "# b"
#print b

c=[0 for i in range(max_t+2)]

for i in b.values():
	for j,k in i:
		#print j,k
		c[j]+=1
		c[k+1]-=1
		#print c
#print c

ans=0
sum=0
for i in c:
	sum+=i
	ans=max(ans,sum)

print ans

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
s_list = []
t_list = []
c_list = []
for i in range(N):
    s_i, t_i, c_i = map(int, input().split())
    s_list.append(s_i)
    t_list.append(t_i)
    c_list.append(c_i)


time = [0 for i in range(max(t_list))]

for i in range(N):
    rg = t_list[i]-s_list[i]+1
    for ii in range(rg):
        time[s_list[i]+ii-1] += 1

print(max(time))

Submission status: Wrong Answer

Solution code:
import numpy as np

n, c = [int(x) for x in input().split()]
schedule = np.zeros((2*(10**5)+1, c+1))
recorder = 0

for _ in range(n):
    start, end, channel = [int(x) for x in input().split()]
    schedule[2*start-1:end*2, channel] += 1

for x in schedule:
    a = sum(x)
    if a > recorder:
        recorder = a

print(int(recorder))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 入力
n, c = map(int, input().split())
p_lists = [list(map(int, input().split())) for i in range(n)]

# 計算
def count(li):
    li = sorted(li)
    m = 1
    count_m = 1
    for i in li:
        print(i, li[li.index(i) + 1:])
        for j in li[li.index(i) + 1:]:
            if len(li[li.index(i) + 1:]) == 1:
                break
            if i[0] <= j[0] <= i[1] or i[0] <= j[1] <= i[1]:
                m -= 1
                if m <= 0:
                    count_m += 1
                    print(2, i, j, count_m)
            else:
                if m < count_m:
                    m += 1
    print(count_m)
    return count_m

# メイン処理
def main():
    print(count(p_lists))

# 実行
main()

Submission status: Wrong Answer

Solution code:
def func():
    tvs = []
    for i in range(num):
        tvs.append((-1, -1))
    for i in range(len(bans)):
        now = bans[i][0]
        can = bans[i][1]
        tvs = [tv for tv in tvs if tv[1] == can] + [tv for tv in tvs if tv[1] != can]
        for j, tv in enumerate(tvs):
            if tv[1] == -1 or (tv[1] == can and tv[0] <= now) or tv[0] <= now - 1:
                del tvs[j]
                tvs.append((bans[i][1], can))
                break
        else:
            return False
    return True


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

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

for num in range(1, 1024):
    if func():
        print(num)
        break

Submission status: Wrong Answer

Solution code:
def func():
    tvs = []
    for i in range(num):
        tvs.append((-1, -1))
    for i in range(len(bans)):
        now = bans[i][0]
        can = bans[i][1]
        for j, tv in enumerate(tvs):
            if tv[1] == -1 or (tv[1] == can and tv[0] <= now) or tv[0] <= now - 1:
                del tvs[j]
                tvs.append((bans[i][1], can))
                break
        else:
            return False
        tvs.sort(key=lambda x: x[0])
    return True


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

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

for num in range(1, 1024):
    if func():
        print(num)
        break

Submission status: Wrong Answer

Solution code:
def func():
    tvs = []
    for i in range(num):
        tvs.append((-1, -1))
    for i in range(len(bans)):
        now = bans[i][0]
        can = bans[i][1]
        for j, tv in enumerate(tvs):
            if tv[1] == -1 or (tv[1] == can and tv[0] <= now) or tv[0] <= now - 1:
                del tvs[j]
                tvs.append((bans[i][1], can))
                break
        else:
            return False
    return True


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

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

for num in range(1, 1024):
    if func():
        print(num)
        break

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
table = [[0]*10000 for i in range(C)]

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

if C == 1:
  print(1)
else:
  print(max(map(sum, zip(*table))))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
table = [[0]*10000 for i in range(C)]

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

print(max(map(sum, zip(*table))))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
S = []
for i in range(N):
    S.append(list(map(int, input().split())))
S.sort()
R = [[] for i in range(C)]
for i in range(N):
    c = S[i][2] - 1
    if R[c]:
        if R[c][-1][1] == S[i][0]:
            R[c][-1][1] = S[i][1]
            continue
    R[c].append(S[i][:])
    R[c][-1][0] -= 0.5
maxDup = 0
for r in R:
    for s in r:
        dup = 1
        for rr in R:
            if rr == r:
                continue
            for ss in rr:
                if (s[0] >= ss[0] and s[0] < ss[1]) or (s[1] >= ss[0] and s[1] <= ss[1]):
                    dup += 1
        if maxDup < dup:
            maxDup = dup
print(maxDup)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from itertools import accumulate

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

imos = [0] * (10 ** 5 + 2)
for c, p in programs.items():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:]:
        if pt == s:
            pt = t
        else:
            imos[ps - 1] += 1
            imos[pt + 1] -= 1
            ps, pt = s, t
    imos[ps - 1] += 1
    imos[pt + 1] -= 1

print(max(accumulate(imos)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from itertools import accumulate

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

imos = [0] * (10 ** 5 + 2)
for c, p in programs.items():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:]:
        if pt == s:
            pt = t
        else:
            imos[ps - 1] += 1
            imos[pt + 1] -= 1
            ps, pt = s, t
    imos[ps] += 1
    imos[pt + 1] -= 1

print(max(accumulate(imos)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from heapq import heapreplace, heappush

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

combined = []
for c, p in programs.items():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:]:
        if pt == s:
            pt = t
        else:
            combined.append((ps, pt, c))
    combined.append((ps, pt, c))
combined.sort()

recorders = [(-1, None)]
for s, t, c in combined:
    end, channel = recorders[0]
    if end < s or c == channel:
        heapreplace(recorders, (t, c))
    else:
        heappush(recorders, (t, c))
print(len(recorders))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop

n,c = map(int, input().split())
queue = [[] for _ in range(c)]

for _ in range(n):
    s,t,c = map(int, input().split())
    if s*2 in queue[c-1]:
        i = queue[c-1].index(s*2)
        queue[c-1][i] = t*2
    elif t*2-1 in queue[c-1]:
        i = queue[c-1].index(t*2-1)
        queue[c-1][i] = s*2-1
    else:
        heappush(queue[c-1], s*2-1)
        heappush(queue[c-1], t*2)
else:
    while [] in queue:
        queue.remove([])

c = len(queue)
max_rec = 0
now_rec = [False for _ in range(c)]
time = 0
while queue:
    time = min(list(zip(*queue))[0])
    
    for channel in range(c):
        if time == queue[channel][0]:
            heappop(queue[channel])
            now_rec[channel] = not now_rec[channel]
    else:
        max_rec = max(sum(now_rec), max_rec)
        while [] in queue:
            queue.remove([])
            c -= 1

else:
    print(max_rec)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, C = map(int, input().split())
table = [[0] * C for i in range(10 ** 5 + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    table[s - 1][c - 1] += 1
    table[t][c - 1] -= 1

imos = [0] * (10 ** 5 + 1)
for i in range(10 ** 5 + 1):
    for j in range(C):
        if table[i][j] == 1:
            imos[i] += 1
        if table[i][j] == -1:
            imos[i] -= 1

ans = 0
for i in range(1, 10 ** 5 + 1):
    imos[i] += imos[i - 1]
    ans = max(ans, imos[i])

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, C = map(int, input().split())
table = [[0] * C for i in range(10 ** 5 + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    table[s - 1][c - 1] = 1
    table[t][c - 1] = -1

imos = [0] * (10 ** 5 + 1)
for i in range(10 ** 5 + 1):
    for j in range(C):
        if table[i][j] == 1:
            imos[i] += 1
        if table[i][j] == -1:
            imos[i] -= 1

ans = 0
for i in range(1, 10 ** 5 + 1):
    imos[i] += imos[i - 1]
    ans = max(ans, imos[i])

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop

n,c = map(int, input().split())
queue = [[] for _ in range(c)]
for _ in range(n):
    s,t,c = map(int, input().split())
    if s*2-1 in queue[c-1]:
        i = queue[c-1].index(s*2-1)
        queue[c-1][i] = t*2-1
    elif t*2-1 in queue[c-1]:
        i = queue[c-1].index(t*2-1)
        queue[c-1][i] = s*2-1
    else:
        heappush(queue[c-1], s*2-1)
        heappush(queue[c-1], t*2-1)
else:
    while [] in queue:
        queue.remove([])

c = len(queue)
max_rec = 0
now_rec = [False for _ in range(c)]
time = 0
while queue:
    time = min(list(zip(*queue))[0])
    
    for channel in range(c):
        if time == queue[channel][0]:
            heappop(queue[channel])
            now_rec[channel] = not now_rec[channel]
    else:
        max_rec = max(sum(now_rec), max_rec)
        while [] in queue:
            queue.remove([])
            c -= 1

else:
    print(max_rec)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, C = map(int, input().split())
table = [0] * (10 ** 5 + 2)
for i in range(N):
    s, t, c = map(int, input().split())
    table[s - 1] += 1
    table[t] -= 1

ans = 0
for i in range(1, 10 ** 5 + 2):
    table[i] += table[i - 1]
    ans = max(ans, table[i])

print(ans)