Problem p03504 (python)

Fixed submission:

N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]
 
record = [[0] * 10 ** 5 for _ in range(C)]
for s, t, c in stc:
    for i in range(s, t + 1):
        record[c-1][i-1] = 1
 
ans = 0
for i in range(10 ** 5):
    cnt = 0
    for j in range(C):
        cnt += record[j][i]
    ans = max(ans, cnt)
 
print(ans)

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

Buggy submission (verdict: Runtime Error):
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                elif end!=lists[j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]
                if j==len(lists[i])-1:
                    sublists.append((start,end))

        lists[i]=sublists

Buggy submission (verdict: Runtime Error):
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(1,31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                elif end!=lists[j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]
                if j==len(lists[i])-1:
                    sublists.append((start,end))

        lists[i]=sublists
    else:
        pass

startlists={i:0 for i in range(100001)}
endlists={i:0 for i in range(100001)}

for i in range(31):
    if len(lists[i])>=1:
        for some in lists[i]:
            startlists[some[0]-1]+=1
            endlists[some[1]]+=1
for i in range(1,100001):
  startlists[i]+=startlists[i-1]
  endlists[i]+=endlists[i-1]


maxi=0
for i in range(100001):
  maxi=max(maxi,startlists[i]-endlists[i])
print(maxi)

Buggy submission (verdict: Runtime Error):
n,c=map(int,input().split())
lists=[[] for i in range(31)]
for i in range(n):
    s,t,c=map(int,input().split())
    lists[c].append((s,t))
for i in range(31):
    lists[c]=sorted(lists[c],key=lambda x:x[0])

for i in range(1,31):
    if len(lists[i])>=2:
        sublists=[]
        start=lists[i][0][0]
        end=lists[i][0][1]
        for j in range(1,len(lists[i])):
                if end==lists[i][j][0]:
                    start=start
                    end=lists[i][j][1]

                elif end!=lists[j][0]:
                    sublists.append((start,end))
                    start=lists[i][j][0]
                    end=lists[i][j][1]
                if j==len(lists[i])-1:
                    sublists.append((start,end))

        lists[i]=sublists
    else:
        pass

startlists={i:0 for i in range(101)}
endlists={i:0 for i in range(101)}

for i in range(31):
    if len(lists[i])>=1:
        for some in lists[i]:
            startlists[some[0]-1]+=1
            endlists[some[1]]+=1
for i in range(1,101):
  startlists[i]+=startlists[i-1]
  endlists[i]+=endlists[i-1]


maxi=0
for i in range(101):
  maxi=max(maxi,startlists[i]-endlists[i])
print(maxi)