Problem p02618 (python)

Fixed submission:
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
#def OutH(lst): print(*lst)
#def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## 貪欲法で、その日に一番スコアが高くなるテストをする

N_ALP = 26

D = iIn()
C = iInLH()
S = iInLD(D)

T = []

for i in range(365):
  print(10)

Buggy submission (verdict: Runtime Error):
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
#def OutH(lst): print(*lst) ## not used for pypy
#def OutV(lst): print(*lst, sep="\n") ## not used for pypy
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## 貪欲法で、その日に一番スコアが高くなるテストをする

N_ALP = 26

D = iIn()
C = iInLH()
S = iInLD(D)

T = []
score = 0
past = [0] * N_ALP
for i in range(D):
    ## 一番スコアが高くなるテストを探す
    ## その日テストiを行うと（相対的に）S[i][T[i]] + C[i] * (past[i]+1) がもらえる
    max_score = 0
    max_idx = 0
    for j in range(N_ALP):
        this_score = S[i][j] + C[i] * (past[i] + 1)
        if this_score > max_score:
            max_idx = j
            max_score = this_score
    T.append(max_idx)
    score += S[i][T[i]]
    past = [x+1 for x in past]
    past[T[i]] = 0
    for j in range(N_ALP):
        score -= C[j] * past[j]
    print(max_idx + 1)

Buggy submission (verdict: Runtime Error):
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## 貪欲法で、その日に一番スコアが高くなるテストをする

N_ALP = 26

D = iIn()
C = iInLH()
S = iInLD(D)

T = []

past = [0] * N_ALP
for i in range(D):
    ## 一番スコアが高くなるテストを探す
    ## その日テストiを行うと（相対的に）S[i][T[i]] + C[i] * (past[i]+1) がもらえる
    max_score = 0
    max_idx = 0
    for j in range(N_ALP):
        score = S[i][j] + C[i] * (past[i] + 1)
        if score > max_score:
            max_idx = j
            max_score = score
    T.append(max_idx)
    past = [x+1 for x in past]
    past[T[i]] = 0

T = [x+1 for x in T]
OutV(T)

Buggy submission (verdict: Runtime Error):
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## 貪欲法で、その日に一番スコアが高くなるテストをする

N_ALP = 26

D = iIn()
C = iInLH()
S = iInLD(D)

T = []

past = [0] * N_ALP
for i in range(D):
    ## 一番スコアが高くなるテストを探す
    ## その日テストiを行うと（相対的に）S[i][T[i]] + C[i] * (past[i]+1) がもらえる
    max_score = 0
    max_idx = 0
    for j in range(N_ALP):
        score = S[i][j] + C[i] * (past[i] + 1)
        if score > max_score:
            max_idx = j
            max_score = score
    T.append(max_idx)
    past = [x+1 for x in past]
    past[T[i]] = 0

OutV(T)