Problem p02618 (python)

Fixed submission:
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

for i in range(D):
  print(s[i].index(max(s[i]))+1)

Buggy submission (verdict: Runtime Error):
import random

def calc(D, s, t):
  last = [0 for _ in range(26)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = random.sample(range(1, 27), k=D)

val = calc(D, s, t)
for _ in range(1000):
  d_rand = random.randrange(1, D+1)
  q_rand = random.randrange(1, 27)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  if val > calc(D, s, t):
    t[d_rand-1] = old
  else:
    val = calc(D, s, t)
for i in range(D):
  print(t[i]+1)

Buggy submission (verdict: Runtime Error):
import random

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]]
    last[t[i]] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

t = random.sample(range(26), k=D)

val = calc(t, D, s)
for _ in range(1000):
  d_rand = random.randrange(D)
  q_rand = random.randrange(26)
  old = t[d_rand]
  t[d_rand] = q_rand
  if val > calc(t, D, s):
    continue
    t[d_rand] = old
  else:
    val = calc(t, D, s)

for i in range(D):
  print(t[i]+1)

Buggy submission (verdict: Runtime Error):
import random

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

t = random.sample(range(1, 27), k=D)

val = calc(t, D, s)
for _ in range(1000):
  d_rand = random.randrange(1, D+1)
  q_rand = random.randrange(1, 27)
  #old = t[d_rand-1]
  #t[d_rand-1] = q_rand
  if val > calc(t, D, s):
    continue
    #t[d_rand-1] = old
  else:
    val = calc(t, D, s)

for i in range(D):
  print(1)
  #print(t[i])

Buggy submission (verdict: Runtime Error):
import random

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

t = random.sample(range(1, 27), k=D)

val = calc(t, D, s)
for _ in range(1000):
  d_rand = random.randrange(1, D+1)
  q_rand = random.randrange(1, 27)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  if val > calc(t, D, s):
    continue
    #t[d_rand-1] = old
  else:
    val = calc(t, D, s)

for i in range(D):
  print(1)

Buggy submission (verdict: Runtime Error):
import random

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

t = random.sample(range(1, 27), k=D)

val = calc(t, D, s)
for _ in range(1000):
  d_rand = random.randrange(1, D+1)
  q_rand = random.randrange(1, 27)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  if val < calc(t, D, s):
    t[d_rand-1] = old
  else:
    val = calc(t, D, s)

for i in range(D):
  print(t[i])

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

for i in range(D):
  for j in range(26):
    day = i + 1
    calc[i] = c[i] * (day - last[i])
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  print(min_idx + 1)