Problem:


Score : 400 points

Problem Statement

Joisino is planning to record N TV programs with recorders.

The TV can receive C channels numbered 1 through C.

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

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

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

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

Constraints

1≤N≤10^5

1≤C≤30

1≤s_i<t_i≤10^5

1≤c_i≤C

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

All input values are integers.

Input

Input is given from Standard Input in the following format:

N C
s_1 t_1 c_1
:
s_N t_N c_N

Output

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

Sample Input 1

3 2
1 7 2
7 8 1
8 12 1

Sample Output 1

2

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

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

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

Sample Input 2

3 4
1 3 2
3 4 4
1 4 3

Sample Output 2

3

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

Sample Input 3

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

Sample Output 3

2



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


Sample output:
2

Submission status: Wrong Answer

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

P = []

for i in range(N):
    s,t,c = list(map(int,input().split()))
    P.append([s-0.5,"S"])
    P.append([t,"T"])

P=sorted(P,key=lambda x:x[0])
count=0
max_count=0
s_buf = 0
t_buf = 0
prev = -1
for i in range(len(P)):
    if prev!=P[i][0]:
        prev=P[i][0]
        count+=s_buf-t_buf
        s_buf=0
        t_buf=0
    if P[i][1]=="S":
        s_buf+=1
    else:
        t_buf+=1
    max_count=max(count,max_count)

count+=s_buf-t_buf
max_count=max(count,max_count)

print(max_count)

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort()
ans = [0 for _ in range(2 * 10 ** 5 + 2)]
for j in range(1, c + 1):
    tt = [0 for _ in range(2 * 10 ** 5 + 2)]
    for i in range(n):
        si, ti, ci = x[i]
        if ci != j:
            continue
        for j in range(2 * si - 1, 2 * ti):
            if tt[j] == 0:
                tt[j] = 1
                ans[j] += 1
print(max(ans))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort(key=lambda x: x[-1])
ans = [0 for _ in range(2 * 10 ** 5 + 2)]
for i in range(n):
    si, ti, ci = x[i]
    for j in range(2 * si - 1, 2 * ti + 1):
        ans[j] += 1
print(max(ans))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort(key=lambda x: x[-1])
ans = [0 for _ in range(2 * 10 ** 5 + 2)]
for i in range(n):
    si, ti, ci = x[i]
    for j in range(2 * si - 1, 2 * ti):
        ans[j] += 1
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, s: "List[int]", t: "List[int]", c: "List[int]"):
    # いもす法
    seq = [0]*(3*10**5)
    for sv, tv, cv in zip(s, t, c):
        seq[2*sv-1] += 1
        seq[2*tv] -= 1
    acc = list(accumulate(seq))
    # print(seq)
    # print(acc)
    print(max(acc))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [int()] * (N)  # type: "List[int]"
    t = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, C, s, t, c)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, s: "List[int]", t: "List[int]", c: "List[int]"):
    # いもす法
    seq = [0]*(10**5+1)
    for sv, tv, cv in zip(s, t, c):
        seq[sv-1] += 1
        seq[tv] -= 1
    acc = list(accumulate(seq))
    # print(seq)
    # print(acc)
    print(max(acc))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [int()] * (N)  # type: "List[int]"
    t = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, C, s, t, c)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
from collections import defaultdict
N,C=map(int,raw_input().split())
S=[];T=[];C=[]
for i in range(N):
    s,t,c=map(int,raw_input().split())
    S.append(s);T.append(t);C.append(c)
beg=defaultdict(int)
end=defaultdict(int)
F=defaultdict(list)
for s,t,c in zip(S,T,C):
    F[c].append((s,t))
for k,v in F.iteritems():
    v.sort()
    buf=[]
    s,t=v[0]
    buf.append((s,t))
    for ss,tt in v[1:]:
        if t!=ss:buf.append((ss,tt))
        s,t=ss,tt
    for s,t in buf:
        beg[2*s-1]+=1
        end[2*t]+=1
ans=-1; cur=0
for i in range(0,max(end)+100):
    cur+=beg[i]
    cur-=end[i]
    ans=max(ans,cur)
print(ans)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
from collections import defaultdict
N,C=map(int,raw_input().split())
S=[];T=[];C=[]
for i in range(N):
    s,t,c=map(int,raw_input().split())
    S.append(s);T.append(t);C.append(c)
beg=defaultdict(int)
end=defaultdict(int)
for s,t,c in zip(S,T,C):
    beg[2*s-1]+=1
    end[2*t]+=1
cur=0
ans=-1
for i in range(0,max(end)+100):
    cur+=beg[i]
    cur-=end[i]
    ans=max(ans,cur)
print(ans)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
from collections import defaultdict
N,C=map(int,raw_input().split())
S=[];T=[];C=[]
for i in range(N):
    s,t,c=map(int,raw_input().split())
    S.append(s);T.append(t);C.append(c)
beg=defaultdict(int)
end=defaultdict(int)
for s,t,c in zip(S,T,C):
    beg[2*s-1]+=1
    end[2*t]+=1
cur=0
ans=-1
for i in range(0,max(end)+100):
    cur+=beg[i]
    ans=max(ans,cur)
    cur-=end[i]
print(ans)

Submission status: Wrong Answer

Solution code:
n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100002
for i in range(n):
    s,t,x=map(int,input().split())
    d[x-1].append((s,t))
print(d)
for i in range(c):
    d[i].sort()
    e=0
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e!=d[i][j][0]:
                w[e+1]-=1
                w[d[i][j][0]]+=1
            w[d[i][j][1]+1]-=1
        else:
            if e==d[i][j][0]:
                e=d[i][j][1]
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)

Submission status: Wrong Answer

Solution code:
n, c = map(int,input().split())
s = [0]*n
t = [0]*n
for i in range(n):
  s[i],t[i],c = map(int,input().split())
s.sort()
t.sort()
j = -1
m = 0
k = 0
for x in s:
  k += 1
  while t[j+1]+1 <= x:
    j += 1
    k -= 1
  m = max(m,k)
print(m)

Submission status: Wrong Answer

Solution code:
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N, _ = list(map(int, input().split()))
S, T, C = zip(*[list(map(int, input().split())) for _ in range(N)])

counts = np.zeros(10 ** 5 + 1, dtype=int)
for s, t, c in zip(S, T, C):
    counts[s - 1] += 1
    counts[t] -= 1
print(np.max(counts.cumsum()))

Submission status: Wrong Answer

Solution code:
n, c = map(int, input().split())
stc = []
for _ in range(n):
  stc.append(tuple(map(int, input().split())))

imos = [(set(), set()) for _ in range(pow(10, 5) + 2)]
for s, t, c in stc:
  if c in imos[s-1][1]:
    imos[s-1][1].remove(c)
  else:
    imos[s-1][0].add(c)
  imos[t-1][1].add(c)

ans = 0
tmp = 0
for _mos in imos:
  tmp += len(_mos[0])
  if ans < tmp:
    ans = tmp
  tmp -= len(_mos[1])

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappush, heappop

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()

ans = 1
recl = [(stc[0][1], stc[0][2])]
for s, t, c in stc[1:]:
  endr = heappop(recl)
  if c == endr[1]:
    heappush(recl, (t, c))
  else:
    if s <= endr[0]:
      if len(recl) + 1 == ans:
        ans += 1
      heappush(recl, (t, c))
      heappush(recl, endr)
    else:
      heappush(recl, (t, c))

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappush, heappop

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()

ans = 1
recl = [(stc[0][1], stc[0][2])]
for s, t, c in stc[1:]:
  endr = heappop(recl)
  if c == endr[1]:
    heappush(recl, (t, c))
  else:
    if s <= endr[0]:
      ans += 1
      heappush(recl, (t, c))
      heappush(recl, endr)
    else:
      heappush(recl, (t, c))

print(ans)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(C)]
An = [0 for j in range(10**5*2+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s] == -1:
    An[s*2] += 1
  else:
    An[s*2-1] += 1
  An[t*2] -= 1

  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

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

print(max(An))

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(C)]
An = [0 for j in range(10**5+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s] == -1:
    An[s] += 1
  else:
    An[s-1] += 1
  An[t] -= 1

  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

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

print(max(An))

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(30)]
An = [0 for j in range(10**5+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s] == -1:
    An[s] += 1
    An[t] -= 1
  else:
    An[s-1] += 1
    An[t] -= 1
  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

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

print(max(An))

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



N,C = map(int, sys.stdin.readline().rstrip().split())
Sn = [0 for i in range(10**5+1)]
Tn = [0 for i in range(10**5+1)]
for i in range(N):
  s,t,c = map(int, sys.stdin.readline().rstrip().split())
  Sn[s-1] += 1
  Tn[t] += 1

Cn = [0 for i in range(10**5+1)]
Cn[0] = Sn[0]
for i in range(1, 10**5+1):
  Cn[i] = Cn[i-1] + Sn[i] - Tn[i]

print(max(Cn))

Submission status: Wrong Answer

Solution code:
#D問題
N,C=map(int,input().split())
S=[]
T=[]
Clist=[]
for i in range(N):
    s,t,c=map(int,input().split())
    S.append(s)
    T.append(t)
    Clist.append(c)
SMAX=max(S)
TMAX=max(T)
Scount=[0 for i in range(TMAX+2)]
Tcount=[0 for i in range(TMAX+2)]
for i in range(N):
    Scount[S[i]]+=1
    Tcount[T[i]]+=1
Ccount=[0 for i in range(C)]
for i in range(N):
    if i != 0:
        if Ccount[Clist[i]-1] == S[i]:
            Scount[S[i]]-=1
    Ccount[Clist[i]-1]=T[i] 
count=[]
for i in range(1,TMAX+1):
    if i == 1:
        kari=0
    else:
        kari=count[-1]
    kari+=Scount[i]
    kari-=Tcount[i-1]
    count.append(kari)
print(max(count))

Submission status: Wrong Answer

Solution code:
#D問題
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)
SMAX=max(S)
TMAX=max(T)
Scount=[0 for i in range(TMAX+2)]
Tcount=[0 for i in range(TMAX+2)]
for i in range(N):
    Scount[S[i]]+=1
    Tcount[T[i]]+=1
count=[]
for i in range(1,TMAX+1):
    if i == 1:
        kari=0
    else:
        kari=count[-1]
    kari+=Scount[i]
    kari-=Tcount[i-1]
    count.append(kari)
print(max(count))

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        for j in range(2):
            time.remove(remove_list[i])
    # time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        for j in range(2):
            time.remove(remove_list[i])
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    time = list(set(time)-set(remove_list))
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(len(time)//2-1):
        if time[2*i+1] == time[2*i+2]:
            remove_list.append(time[2*i+1])
    time = list(set(time)-set(remove_list))
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    for i in range(len(time)//2-1):
        if time[2*i+1] == time[2*i+2]:
            remove_list.append(time[2*i+1])
    time = list(set(time)-set(remove_list))
    time.sort()
    # print(time)
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)

Submission status: Wrong Answer

Solution code:
N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in channells.keys():
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        time.remove(remove_list[i])
        time.remove(remove_list[i])
    # print(time)
    # print(f)
    for i in range(len(time)//2):
        f[time[2*i]] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

print(ans)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

N,C = map(int,input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]
# print(tv_times)

max_end = -1
for i in range(N):
    max_end = max(tv_times[i][1],max_end)

# print(max_end)
count = [0 for i in range(max_end)]
for ni in range(N):
    for time in range(max(tv_times[ni][0]-1,0),tv_times[ni][1]):
        count[time] += 1

# print(count)
print(max(count))


"""
[S-1~T]

Q1
3 2
1 7 2
7 8 1
8 12 1


つまり
0.5~7
6.5~8
7.5~12
"""

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int,input().split())
 
nofc=np.zeros(10**5+1,dtype=int)
 
for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1,dtype=int)
  nofc[s:t+1]=vec
print(int(max(nofc)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int,input().split())

nofc=np.zeros((C,10**5),dtype=int)

for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1,dtype=int)
  nofc[c-1][s-1:t]+=vec
print(int(max(np.sum(nofc,axis=0))))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int,input().split())

nofc=np.zeros(10**5,dtype=int)

for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1,dtype=int)
  
  nofc[s-1:t]+=vec
  #print(vec)
  #print(nofc[:13])
print(int(max(nofc)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int,input().split())
 
nofc=np.zeros(10**5+1,dtype=int)
 
for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1,dtype=int)
  
  nofc[s-1:t]+=vec
  #print(vec)
  #print(nofc[:13])
print(int(max(nofc)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int,input().split())
 
nofc=np.zeros(10**5+1,dtype=int)
 
for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1,dtype=int)
  
  nofc[s:t+1]+=vec
  #print(vec)
  #print(nofc[:13])
print(int(max(nofc)))

Submission status: Wrong Answer

Solution code:
import collections
n,c  = map(int,input().split())                     
channels = [list(map(int,input().split())) for i in range(n)]
channel_set = [list(range(i[0]-1,i[1])) for i in channels]
channels = []                                                
for ch in channel_set:
    channels.extend(ch)                                                                   
#map(int,input().split())    
c = collections.Counter(channels)
print(c.most_common()[0][1])

Submission status: Wrong Answer

Solution code:
import collections
n,c  = map(int,input().split())                     
channels = [list(map(int,input().split())) for i in range(n)]
channel_set = [list(range(i[0],i[1]+1)) for i in channels]
channels = []                                                
for ch in channel_set:
    channels.extend(ch)                                                                   
#map(int,input().split())    
c = collections.Counter(channels)
print(c.most_common()[0][1])

Submission status: Wrong Answer

Solution code:
import numpy as np
N,C=map(int,input().split())

nofc=np.zeros(10**5+1)

for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1)
  
  nofc[s:t+1]+=vec
  #print(vec)
  #print(nofc[:13])
print(int(max(nofc)))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
T=2*10**5+4
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,k=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(k)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]*2]+=1
            tt[r[j]*2+1]-=1
    for j in range(T-1):
        tt[j+1]+=tt[j]
    for j in range(T):
        if tt[j]>0:
            sm[j]+=tt[j]
        else:
            sm[j]+=tt[j]
#for j in range(T-1):
#    sm[j+1]+=sm[j]
print(max(sm))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
T=10**5+2
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,k=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(k)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]]+=1
            tt[r[j]+1]-=1
    for j in range(T-1):
        tt[j+1]+=tt[j]
    for j in range(T):
        if tt[j]>0:
            sm[j-1]+=tt[j]
        else:
            sm[j]+=tt[j]
#for j in range(T-1):
#    sm[j+1]+=sm[j]
print(max(sm))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
T=10**5+2
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,k=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(k)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]]+=1
            tt[r[j]+1]-=1
    for j in range(T):
        if tt[j]>0:
            sm[j-1]+=tt[j]
        else:
            sm[j]+=tt[j]
for j in range(T-1):
    sm[j+1]+=sm[j]
print(max(sm))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
T=2*10**5+4
t=10**5+2
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,k=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(k)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]*2]+=1
            tt[r[j]*2+1]-=1
    for j in range(T):
        if tt[j]>0:
            sm[j-1]+=tt[j]
        else:
            sm[j]+=tt[j]
for j in range(T-1):
    sm[j+1]+=sm[j]
print(max(sm))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
T=2*10**5+4
t=10**5+2
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,C=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(C)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]*2]+=1
            tt[r[j]*2+1]-=1
    for j in range(1,T):
        tt[j]+=tt[j-1]
    for j in range(T):
        sm[j]+=tt[j]
print(max(sm))

Submission status: Wrong Answer

Solution code:
N,C=map(int,input().split())
T=2*10**5+2
t=10**5+1
sm=[0]*(T)
l=[]
r=[]
c=[]
for i in range(N):
    s,t,C=map(int,input().split())
    l.append(s)
    r.append(t)
    c.append(C)
for i in range(1,C+1):
    tt=[0]*T
    for j in range(N):
        if c[j]==i:
            tt[l[j]*2-1]+=1
            tt[r[j]*2]-=1
    for j in range(1,T):
        tt[j]+=tt[j-1]
    for j in range(T):
        if tt[j]>0:
            sm[j]+=1
mx=0
for i in range(T):
    mx=max(mx,sm[i])
print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, C = mi()
time = [0 for i in range(10 ** 5 + 10)]
use = [[] for i in range(10 ** 5 + 10)]
for i in range(N):
    s, t, c = mi()
    use[t].append(c)
    if c in use[s]:
        time[s] += 1
    else:
        time[s-1] += 1
    time[t] -= 1
# print(time[0:100])
timesum = np.cumsum(np.array(time))
# print(use[0:100])
print(max(timesum))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, C = mi()
time = [0] * (10**5+10)
for i in range(N):
    s, t, c = mi()
    time[s - 1] += 1
    time[t] -= 1
timesum = np.cumsum(np.array(time))
print(max(timesum))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,ch = li()
MAX_T = 10**5+1

program = [[0]*MAX_T for _ in range(ch)]

endset = [set() for _ in range(ch)]
stc = []

for _ in range(n):
    s,t,c = li()
    c -= 1
    
    stc.append((s,t,c))
    endset[c].add(t)
    
for s,t,c in stc:
    if s in endset[c]:
        continue
    
    program[c][s-1] += 1
    program[c][t] -= 1
    
for ci in range(ch):
    program[ci] = list(accumulate(program[ci]))
    
print(max([sum(time_span) for time_span in zip(*program)]))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

def concat(channel: list):
    for ti in range(len(channel)):
        if channel[ti] == 1 and channel[ti+1] == -1:
            channel[ti] = 0
            channel[ti+1] = 0

n,ch = li()
MAX_T = 10**5+1

program = [[0]*MAX_T for _ in range(ch)]

for _ in range(n):
    s,t,c = li()
    c -= 1
    
    program[c][s-1] += 1
    program[c][t] -= 1
    
for ci in range(ch):
    concat(program[ci])
    program[ci] = list(accumulate(program[ci]))
    
print(max([sum(time_span) for time_span in zip(*program)]))

Submission status: Wrong Answer

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

_l = [[0 for _ in range(2*int(1e5+1))] for _ in range(C+1)]

for s,t,c in STC:
  if _l[c][2*s] == -1:
    _l[c][2*s] = 0
    _l[c][2*t] = -1
  else:
    _l[c][2*s-1] += 1
    _l[c][2*t] -= 1

import numpy as np

_l = np.array(_l)

ac = (_l.sum(axis=0)).cumsum()
print(max(ac))

Submission status: Wrong Answer

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

_l = [[0 for _ in range(int(1e5+1))] for _ in range(C+1)]

for s,t,c in STC:
  if _l[c][s] == -1:
    _l[c][s] = 0
    _l[c][t] = -1
  else:
    _l[c][s-1] += 1
    _l[c][t] -= 1

import numpy as np

_l = np.array(_l)

ac = (_l.sum(axis=0)).cumsum()
print(max(ac))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n, c = map(int, input().split())
tmp_info = [list(map(int, input().split())) for i in range(n)]

tmp_info = sorted(tmp_info, key=itemgetter(2))
info = []
for i in range(n):
    if not info:
        info.append(tmp_info[i])
    elif info[-1][1] == tmp_info[i][0] and info[-1][2] == tmp_info[i][2]:
        info[-1][1] =tmp_info[i][1]
    else:
        info.append(tmp_info[i])
info = sorted(info, key=itemgetter(1))
n = len(info)
li = []

for i in range(n):
    li = sorted(li, reverse=True)
    for j in range(len(li)):
        if info[i][0] > li[j]:
            li[j] = info[i][1]
            break
    else:
        li.append(info[i][1])
        
print(len(li))

Submission status: Wrong Answer

Solution code:
N, C = map(int, input().split())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))

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

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

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
n, c = na()
stc = []
for i in range(n):
    stc.append(na())
stc.sort(key=lambda x: (x[2], x[0]))

nstc=[]
for i in range(n):
    if(len(nstc)>0 and nstc[-1][2]==stc[i][2] and nstc[-1][1]==stc[0]):
        nstc[-1][1]=stc[i][1]
    else:
        nstc.append(stc[i])
n=len(nstc)
h=[0]*200005
for i in range(n):
    h[2*nstc[i][0]-1]+=1
    h[2*nstc[i][1]]+=-1
for i in range(len(h)-1):
    h[i]+=h[i-1]
print(max(h))