Problem:


(Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.)

Beginner's Guide

Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.

Problem Statement

You will be given a contest schedule for D days.
For each d=1,2,\ldots,D, calculate the satisfaction at the end of day d.

Input

Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.

D
c_1 c_2 \cdots c_{26}
s_{1,1} s_{1,2} \cdots s_{1,26}
\vdots
s_{D,1} s_{D,2} \cdots s_{D,26}
t_1
t_2
\vdots
t_D

The constraints and generation methods for the input part are the same as those for Problem A.

For each d, t_d is an integer satisfying 1\leq t_d \leq 26, and your program is expected to work correctly for any value that meets the constraints.

Output

Let v_d be the satisfaction at the end of day d.
Print D integers v_d to Standard Output in the following format:

v_1
v_2
\vdots
v_D

Sample Input 1

5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192
1
17
13
14
13

Sample Output 1

18398
35037
51140
65837
79325

Note that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.

Next Step

We can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,\ldots,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of "greedy algorithms" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!

Greedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.
We can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.
For more information, please refer to the editorial that will be published after the contest.



Sample input:
5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192
1
17
13
14
13


Sample output:
18398
35037
51140
65837
79325

Submission status: Wrong Answer

Solution code:
import numpy as np
from time import time
start = time()
def scoring(c,s,t):
    score = 0
    from_last = np.zeros(26)
    for i in range(s.shape[0]):
        from_last = from_last+1
        score += s[i,t[i]-1]
        from_last[t[i]-1] = 0
        score = score - (c*from_last).sum()
    return score


D = int(input())
c = list(map(int,input().split()))
s = np.empty((D,26))
for i in range(D):
    s[i,:] = np.array(list(map(int,input().split())))


t = []
for i in range(D):
    chosen = s[i,:].flatten().argmax()+ 1
    t.append(chosen)


score = scoring(c,s,t)
while time()-start < 1.85:
    i = np.random.randint(D)
    old = t[i]
    t[i] = np.random.randint(1,27)
    new_score = scoring(c,s,t)
    if new_score > score:
        score = new_score
    else:
        t[i] = old

for i in t:
	print(i)

Submission status: Wrong Answer

Solution code:
from operator import mul
def plus(n):
    return n+1


rows = int(input())
c = list(map(int, input().split()))
s = [[int(j) for j in input().split()] for i in range(rows)]

for i in range(rows):
    print(i)

Submission status: Wrong Answer

Solution code:
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
t = [int(input()) for _ in range(D)]
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return -1
def last(d,i):
    a= t[:d]
    reversed(a)
    day = my_index(a,i)+1
    return day
score = 0
for d in range(1,D+1):
    score += s[d-1][t[d-1]-1]
    for i in range(1,27):
        score -= c[i-1]*(d-last(d,i))
    print(score)

Submission status: Wrong Answer

Solution code:
def yumiri(L, n):
  for i in range(len(L)):
    if L[i] > n:
      return i - 1

def naobou(d, q):
  newans = ans

  rd = t[d - 1] - 1
  rq = yumiri(ZL[rd], d)
  newans += SUMD[ZL[rd][rq] - ZL[rd][rq - 1] - 1] * c[rd]
  newans += SUMD[ZL[rd][rq + 1] - ZL[rd][rq] - 1] * c[rd]
  newans -= SUMD[ZL[rd][rq + 1] - ZL[rd][rq - 1] - 1] * c[rd] 
  del ZL[rd][rq]

  nd = q - 1
  nq = yumiri(ZL[nd], d)
  newans += SUMD[ZL[nd][nq + 1] - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[d - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[ZL[nd][nq + 1] - d - 1] * c[nd]
  ZL[nd].insert(nq + 1, d)

  newans -= s[d - 1][rd]
  newans += s[d - 1][nd]

  if newans < ans:
    ZL[rd].insert(rq, d)
    del ZL[nd][nq + 1]
    return ans
  else:
    t[d - 1] = q
    return newans 

def rieshon():
  ans = 0
  for i in range(D):
    ans += s[i][t[i] - 1]
    for j in range(26):
      if t[i] - 1 == j:
        L[j] = 0
        ZL[j].append(i + 1)
      else:
        L[j] += 1
        ans -= L[j] * c[j]
  for i in range(26):
    ZL[i].append(D + 1)
  return ans

import time
import random
startTime = time.time()

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

L = [0] * 26
ZL = [[0] for _ in range(26)]
SUMD = [0] * (D + 1)
for i in range(1, D + 1):
  SUMD[i] = SUMD[i - 1] + i

t = [0] * D
for i in range(D):
  ma = s[i][0]
  man = 0
  for j in range(1, 26):
    if s[i][j] == ma:
      if c[j] < c[man]:
        ma = s[i][j]
        man = j
    elif s[i][j] > ma:
      ma = s[i][j]
      man = j
  t[i] = man + 1

ans = rieshon()
while time.time() - startTime < 1.8:
  d = random.randrange(D) + 1
  q = random.randrange(26) + 1
  if t[d - 1] == q: continue
  ans = naobou(d, q)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365+1)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)

v = 0
for d in range(D):
  av = s[d] - sum( c*(d-last) ) + c*(d-last) 
  t =  int(input())
  t -= 1
  last[t] = d
  v += av[t]
  print(t+1, v )
#

Submission status: Wrong Answer

Solution code:
D, C = int(input()),list(map(int,input().split()))
sumone = 0
cs = sum(C)
lastcs = [0]
for i in range(1,D+1):
  currentday = list(map(int,input().split()))
  sumone += max(currentday)
  typed = currentday.index(max(currentday))+1
  lastcs.append(typed)
  cc = cs*i
  for j in range(1,i+1):
    if lastcs[j] == typed and j != i:
       cc -= 0
    else:
      cc -= C[lastcs[j]-1]*j
  sumone = sumone - cc
  print(sumone)

Submission status: Wrong Answer

Solution code:
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
sum_c=sum(c)
t=[]
for i in range(D):
  max_s=0
  for j in range(26):
    hantei=s[i][j]-sum_c+c[j]
    if hantei>max_s:
      max_s=hantei
      index=j
  t.append(index)
last_di=[0]*26
m=0
for i in range(D):
  m+=s[i][t[i]-1]
  last_di[t[i]-1]=i+1
  for j in range(26):
    m-=c[j]*((i+1)-last_di[j])
  print(m)

Submission status: Wrong Answer

Solution code:
D=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split()))  for i in range(D)]
t=[int(input()) for i in range(D)]

d=[-1]*(26)
v=[0]*(D+1)


for i in range(D):
    v[i]=s[i][t[i]-1]
    d[t[i]-1]=0
    sb=0      
    for j in range(26):
        if d[j]!=-1:
            d[j]+=1
            sb+=d[j]*c[j]            
    v[i]+=v[i-1]-sb
    print(v[i])

Submission status: Wrong Answer

Solution code:
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + x[j]*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])

Submission status: Wrong Answer

Solution code:
def complain(comp,c,k,last_hold,i):
    # print(k)
    if(k > 26):
        # print("___")
        return comp
    comp += c[k-1]*((i+1) - last_hold[k-1]) 
    k += 1
    # print(comp,"comp")
    return complain(comp,c,k,last_hold,i)

D = int(input())
c = list(map(int,input().split()))
s = ["_"]*(D)
print(c)
for i in range(D):
    s[i] = list(map(int,input().split()))
last_hold = [0]*26
score = [0]*(D+1)

for i in range(D):
    score[i+1] += score[i]
    t = int(input())
    last_hold[t-1] = i+1
    comp = 0
    k = 1
    score[i+1] += s[i][t-1]    
    # print(s[i][t-1],"s")
    comp = complain(comp,c,k,last_hold,i)    
    score[i+1] -= comp
    # print(comp,"comp")
    # print(score[i+1],"score")

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

# Σ(Ci * (d - last(d,i)))
# (1~26)

# 18398
# 35037
# 51140
# 65837
# 79325

Submission status: Wrong Answer

Solution code:
d =int(input())
c = list(map(int, input().split())) 
s = []
t = []

d_l = []
score = 0
soft = 0

for i in range(d):
    s.append(0)
    s[i] = list(map(int, input().split()))

for i in range(26):
    d_l.append(0)
    
for i in range(d):
    t = int(input())
    soft = 0
    
    for j in range(26):
        if t-1 == j:
            d_l[j] = 0
            score = s[i][j]
        else:
            d_l[j] += 1
            soft += c[j] * d_l[j]
    
    score -= soft
    print(score)

Submission status: Wrong Answer

Solution code:
#B
D = int(input())
c = [0] + list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = list(map(int, input().split()))

last = [0] * 27
manzoku = [0] * 27
for i in range(1, D+1):
    for j in range(1, 27):
        if last[j] != 0:
            manzoku[j] -= c[j] * (i - last[j])
    manzoku[s[i-1].index(max(s[i-1]))] += max(s[i-1])
    last[s[i-1].index(max(s[i-1]))] = i
    
    result = 0
    for k in range(27):
        result += manzoku[k]
    print(result)

Submission status: Wrong Answer

Solution code:
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [int(input()) - 1 for i in range(d)]
L = [-1 for j in range(26)]
score = 0
for i in range(d):
    up = S[i][T[i]]
    down = 0
    for j in range(26):
        if T[i] == j:
            L[j] = i
        else:
            down += C[j] * (i - L[j])
    score = max(score + up - down, 0)
    print(score)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    s = input().rstrip()
    t = input().rstrip()

    count = 0

    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1

    print(count)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

last = [0]*26
ans = 0
for d in range(D):
    max_s = s[d].index(max(s[d]))
    last[max_s] = d+1
    ans += max(s[d])
    for i in range(26):
        ans -= c[i]*(d+1 - last[i])
    print(ans)

Submission status: Wrong Answer

Solution code:
def get_score(day, contest, prev_list, loss_list, satisfied_matrix):
    plus = satisfied_matrix[day][contest]
    minus = 0
    for type, prev in enumerate(prev_list):
        if type == contest:
            continue
        spend = day - prev
        minus += loss_list[type] * spend

    return plus - minus



days = int(input())
loss_list = list(map(int, input().split()))
satisfied_matrix = [list(map(int, input().split())) for _ in range(days)]

prev_list = [-1] * 26

ans = []
for day in range(days):
    best_contest = 0
    best_score = 0
    for contest in range(26):
        score = get_score(day, contest, prev_list, loss_list, satisfied_matrix)
        if score > best_score:
            best_contest = contest
            best_score = score

    ans.append(best_contest)
    prev_list[best_contest] = day

print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
D = int(input())
C = list(map(int, input().split()))  # (#cty,)
S = [list(map(int, input().split())) for _ in range(D)]  # (D, #cty)
T = [int(input()) for _ in range(D)]  # (D,)


class Scorer:

    def __init__(self, d, c, s):
        n_cty = len(c)
        self.c = c  # (#cty,)
        self.s = s  # (D, #cty)
        self.elapsed_time = {cty: 0 for cty in range(n_cty)}

        self.cur = 0

    def score(self, d, cty):
        # update elapsed time
        for cty_ in self.elapsed_time:
            if cty_ == cty:
                self.elapsed_time[cty_] = 0
            else:
                self.elapsed_time[cty_] += 1
        print(self.elapsed_time)

        score = self.s[d][cty]
        for cty_ in self.elapsed_time:
            score -= self.c[cty_] * self.elapsed_time[cty_]
        self.cur += score
        return self.cur


scorer = Scorer(D, C, S)

for d in range(D):
    cty = T[d] - 1
    print(scorer.score(d, cty))

Submission status: Wrong Answer

Solution code:
def last(i, ti, t):
    for k in reversed(range(i + 1)):
        if ti == t[k]:
            return k + 1
        else:
            return 0
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    si = list(map(int, input().split()))
    s.append(si)
t = []
for i in range(d):
    t.append(int(input()))
    
v = [0 for _ in range(d)]
for i in range(d):
    v[i] += s[i][t[i]-1]
    if i > 1:
        for j in range(26):
            v[i] -= c[j]*(i - last(i, t[i], t))
    print(v[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

D=int(input())#365
c=list(map(int,input().split()))
s=np.array([])
for i in range(D):
  if(i<16):
    print((i+10)%26+1)
  else:
    s=np.array([input().split()], dtype=np.int64)
    max_space=np.argmax(s)
    print(max_space+1)

Submission status: Wrong Answer

Solution code:
def complain(comp,c,k,last_hold):
    # print(k)
    if(k > 26):
        # print("___")
        return comp
    comp += c[k-1]*((i+1) - last_hold[k-1]) 
    k += 1
    # print(comp,"comp")
    return complain(comp,c,k,last_hold)

D = int(input())
c = list(map(int,input().split()))
s = ["_"]*(D)
print(c)
for i in range(D):
    s[i] = list(map(int,input().split()))
last_hold = [0]*26
score = [0]*(D+1)

for i in range(D):
    score[i+1] += score[i]
    t = int(input())
    last_hold[t-1] = i+1
    comp = 0
    k = 1
    score[i+1] += s[i][t-1]
    # print(s[i][t-1],"s")
    score[i+1] -= complain(comp,c,k,last_hold)
for i in range(D):
    print(score[i+1])

# Σ(Ci * (d - last(d,i)))
# (1~26)

Submission status: Wrong Answer

Solution code:
D=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split()))  for i in range(D)]
t=[int(input()) for i in range(D)]

d=[-1]*(26)
v=[0]*(D+1)


for i in range(D):
    v[i]=s[i][t[i]-1]
    d[t[i]-1]=0
    if i>0: 
        sb=0      
        for j in range(26):
            if d[j]!=-1:
                d[j]+=1
                sb+=d[j]*c[j]            
        v[i]+=v[i-1]-sb
    print(v[i])

Submission status: Wrong Answer

Solution code:
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [int(input()) - 1 for i in range(d)]
L = [-1 for j in range(26)]
score = 0
for i in range(d):
    score += S[i][T[i]]
    for j in range(26):
        if T[i] == j:
            L[j] = i
        else:
            score -= C[j] * (i - L[j])
            score = max(score, 0)
    print(score)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
import numpy as np
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

D = ni()
c = na()
s = [na() for _ in range(D)]
out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26

for d in range(D):
    assert(1 <= out[d] and out[d] <= 26)
    idx = -1
    li = []
    for k in range(26):
        last_t = last
        sat_t = sat
        j = k
        last_t[j] = d + 1
        for i in range(26):
            sat_t -= (d + 1 - last_t[i]) * c[i]
        sat_t += s[d][j]
        li.append(sat_t)
    sat = max(li)
    last[np.argmax(li)] = d + 1
    print(sat)

Submission status: Wrong Answer

Solution code:
d = int(input())

c = list(map(int,input().split()))

s = []

for _ in range(d):
    temp = list(map(int,input().split()))

    s.append(temp)

def calc_point(point_list, interval, choice):
    point = 0

    for i, day in enumerate(interval):
        point -= c[i] * day

    point += point_list[choice - 1]

    return point

interval = [0] * 26

result = 0

for i in range(d):
    temp = [x - c[i] * day for i, (x, day) in  enumerate(zip(s[i], interval))]

    choice = s[i].index(max(s[i])) + 1

    interval = [x + 1 for x in interval]

    interval[choice - 1] = 0

    result += calc_point(s[i], interval, choice)

    print(result)

Submission status: Wrong Answer

Solution code:
d=int(input())
a=[]
for x in range(d+1):
  b=list(map(int,input().split()))
  a.append(b)
  
  

sum1=sum(a[0][1:d])

ans=[0]*d

for n in range(d):
  ans[n]=(a[n+1][0])
  ans[n]=int(int(ans[n])-(sum1))
  try:
    ans[n]=ans[n]+ans[n-1]
  except:
    True
    
for y in range(d):
  print(ans[y])

Submission status: Wrong Answer

Solution code:
D = int(input())
c = list(map(int,input().split()))
s = list(list(map(int,input().split())) for i in range(D))
t = []
score = 0
last = [0]*26
#v = [0]*D

def calc(d):
    """
    貪欲法でd日目のスコアが最も高くなるコンテストを出力
    """
    score = 0
    t = 0
    for i in range(26):
        temp = 0
        temp += s[d][i]
        for j in range(26):
            temp -= c[j]*(d+1-last[j])
        if score > temp:
            pass
        else:
            score = temp
            contest = i
    return i

for d in range(D):
    i = calc(d)
    t.append(i)
    last[i] = d+1
for i in range(D):
    print(t[i])

Submission status: Wrong Answer

Solution code:
import numpy as np
D=int(input())
C=map(int,input().split())
C=list(C)
S=[]
for i in range(D):
  S.append(list(map(int,input().split())))
T=[]
for i in range(D):
  T.append(int(input()))
Sum=0
for i in range(D):
  t=int(T[i])
  Sum+=S[i][t-1]
Count=np.ones(26)
minus=0
for i in range(D):
  for j in range(26):
    if j!=(T[i]-1):
      minus+=C[j]*Count[j]
      Count[j]=Count[j]+1
    else:
      minus=minus
  Count[T[i]-1]=1
print(Sum-minus)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		for j,vol in enumerate(val):
			if tmp == vol:
				ans.append(2)
				break

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

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
d = int(input())
cList = input().split()

sList = []

for idx in range(0, d):
    tempList = input().split()
    sList.append(tempList)

tList = []

for idx in range(0, d):
    tList.append(int(input()))


print(sList)
print(tList)

countList = [0] * 26
val = 0

for idx in range(0, d):
    val += int(sList[idx][tList[idx] -1])

    countList = list(map(lambda x: x+1, countList))
    countList[int(tList[idx]) -1] = 0

    for wkChar in range(0,26):
        val -= int(countList[wkChar]) * int(cList[wkChar])
    print(val)

Submission status: Wrong Answer

Solution code:
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [int(input()) - 1 for i in range(d)]
L = [-1 for j in range(26)]
score = 0
for i in range(d):
    score += S[i][T[i]]
    for j in range(26):
        if T[i] == j:
            L[j] = i
        else:
            score -= C[j] * (i - L[j])
    score = max(score, 0)
    print(score)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import time
import numpy as np

start = time.time()
limit_time = 1.8

# 整数の入力
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

def point(t):
    result = 0
    map = {
        0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
        10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,
        20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0
    }
    for i in range(d):
        comp = t[i] - 1
        day = i + 1
        map[comp] = day
        result = result + s[i][comp]
        for cc in range(26):
            result = result - c[cc] * (day - map[cc])
        print(result)
    return result

t = [int(input()) for i in range(d)]

Submission status: Wrong Answer

Solution code:
d=int(input())
a=[]
for x in range(d+1):
  b=list(map(int,input().split()))
  a.append(b)
  
  

print(a[1][1])
sum1=sum(a[0][1:d])

ans=[0]*d

for n in range(d):
  ans[n]=(a[n+1][0])
  ans[n]=int(int(ans[n])-(sum1))
  try:
    ans[n]=ans[n]+ans[n-1]
  except:
    True
    
for y in range(d):
  print(ans[y])

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate
import bisect

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    D = ii()
    c = list(mi())
    s = [list(mi()) for i in range(D)]

    t = [ii()-1 for i in range(D)]

    last = [[0]*26 for i in range(D)]
    v = [0]*D

    for d in range(D):
        for i in range(26):
            if i == t[d]:
                last[d][i] = d+1
            else:
                last[d][i] = last[d-1][i]

        k = sum(c[i]*(d+1-last[d][i]) for i in range(26))
        v[d] = v[d-1] + s[d][t[d]] - k
    
    print(v)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
D = int(input())
C = list(map(int, input().split()))
S = list(list(map(int, input().split())) for i in range(D))
T = list(int(input()) for i in range(D))
manzoku = 0
yasumi= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print(len(yasumi))
#1日目
for day in range(D):
  yasumi = list(map(lambda x: x + 1, yasumi))
  yasumi[T[day] - 1] = 0
  manzoku += S[day][T[day] - 1]
  for i in range(26):
    manzoku -= C[i] * yasumi[i]
  print(manzoku)

Submission status: Wrong Answer

Solution code:
#B

import numpy as np
D = int(input())
C = list(map(int,input().split()))
S = np.empty((D,26),dtype=np.int8)
for i in range(D):
    l = list(map(int,input().split()))
    for j in range(26):
        S[i][j] = l[j]
        
#開催日時の記録
R = np.zeros(26)

sc = 0
for i in range(1,D+1):
    
    #ランダムに開催するコンテストを選ぶ
    con = int(input()) - 1
    
    #スコア計算
    #コンテスト開催による上昇
    sc += S[i-1][con]
    R[con] = i
    
    #コンテスト非開催による減少
    for j in range(26):
        sc -= C[j]*(i-R[j])
        
    print(sc)

Submission status: Wrong Answer

Solution code:
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [int(input()) - 1 for i in range(d)]
L = [0 for j in range(26)]
score = 0
for i in range(d):
    score += S[i][T[i]]
    for j in range(26):
        if T[i] == j:
            L[j] = i + 1
        score -= C[j] * (i + 1 - L[j])
    score = max(score, 0)
    print(score)

Submission status: Wrong Answer

Solution code:
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    last = [0]*26
    ans = []
    for d in range(D):
        score = 0
        t = 0
        for i in range(26):
            tmp = S[d][i]
            for j in range(26):
                if i != j:
                    tmp -= C[j]*(d + 1 - last[j])
            if tmp > score:
                score = tmp
                t = i + 1
        last[t - 1] = d + 1
        ans.append(t)
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [int(input()) - 1 for i in range(d)]
L = [-1 for j in range(26)]
score = 0
for i in range(d):
    score += S[i][T[i]]
    for j in range(26):
        if T[i] == j:
            L[j] = i
        score -= C[j] * (i - L[j])
    score = max(score, 0)
    print(score)

Submission status: Wrong Answer

Solution code:
# 入出力から得点を計算する
import sys
input = lambda: sys.stdin.readline().rstrip()
D = int(input())
c = list(map(int, input().split()))
s = [[int(i) for i in input().split()] for _ in range(D)]
t = []
for i in range(D):
    tmp = int(input())
    t.append(tmp)

result = 0
last_day = [0 for _ in range(26)]
last_day[0] = 1

for i in range(len(t)):
    # 選んだコンテスト
    choose = t[i] - 1
    last_day[choose] = i + 1

    # そのコンテストを選んだ時の本来のポイント
    tmp_point = s[i][choose]

    # そこから満足度低下分をマイナス
    for j in range(26):
        tmp_point -= c[j] * ((i+1) - last_day[j])
    result += tmp_point
    print(result)
# print(c,s,t)

Submission status: Wrong Answer

Solution code:
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
t = [int(input()) for i in range(D)]

last = {}
for i in range(1,27):
    last[i] = 0

satisfaction = 0
for d in range(1,D+1):
    satisfaction += s[d-1][t[d-1]-1]
    last[t[d-1]] = d
    for i in range(1,27):
        satisfaction -= c[i-1]*(d-last[i])
    print(satisfaction,s[d-1][t[d-1]-1])

Submission status: Wrong Answer

Solution code:
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]

for s in S:

    print(s.index(max(s))+1)

Submission status: Wrong Answer

Solution code:
D = int(input())#D=365
c = list(map(int, input().split()))#0<=c<=100
s = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [int(input()) for _ in range(D)]


v = []
last = [0] * 26
value = 0
for d in range(D):
    for i in range(26):
        value += s[d][i]
        value += c[i] * (d - last[i])
    v.append(value)

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

Submission status: Wrong Answer

Solution code:
d = int(input())
C = list(map(int, input().split()))
S = []
for i in range(d):
    S.append(list(map(int, input().split())))
T = [0]
for i in range(d):
    T.append(int(input()))
print(S)
print(T)

#最終開催日
Last = [0] * 26

#各Scores
Scores = [0] * 26

for day in range(1, d+1):
    contest = T[day] - 1
    Last[contest] = day
    Scores[contest] += S[day-1][contest]
    for num in range(26):
        Scores[num] -= C[num] * (day - Last[num])
    print(sum(Scores))

Submission status: Wrong Answer

Solution code:
import numpy as np

D = int(input())
c = list(map(int, input().split()))
c = np.array(c)
S = np.zeros([D, 26], dtype=int)
for i in range(D):
  S[i, :] = list(map(int, input().split()))

T = []
last = np.zeros(26)

for i in range(D):
  score = S[i, :] - (i-last)*np.array(c)
  #argmax = score.argmax()
  #t = argmax
  #last[t] = i
  print(int(score.max()))

Submission status: Wrong Answer

Solution code:
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
#t = [int(input()) for _ in range(d)]
ans = 0
last = [0]*26
for i in range(1,d+1):
    x = 0
    #x = t[i-1]-1
    #x = random.randrange(26)
    last[x] = i
    ans += s[i-1][x]
    for j in range(26):
        ans -= c[j]*(i-last[j])
    print(ans)

Submission status: Wrong Answer

Solution code:
d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
    s_i=list(map(int,input().split()))
    s.append(s_i)
t=[]
for _ in range(d):
    t_i=int(input())
    t.append(t_i)


dp=[0]*26

ans=0
for i in range(d):
    s_i = s[i][t[i]-1]

    index=t[i]-1
    
    dp[index]=i+1

    tmp=0

    for j in range(26):
        tmp+=c[j]*(d-dp[j])

    ans += s_i - tmp
    print(ans)

Submission status: Wrong Answer

Solution code:
D = int(input())
c_list = list(map(int, input().split()))
s_list, t_list = [], []
for i in range(D):
    s_list.append(list(map(int, input().split())))

for i in range(D):
    t_list.append(int(input()))

base = 1000000
S = 0

contests_held_day = []
for i in range(26):
    contests_held_day.append(0)

for i in range(D):
    S += s_list[i][t_list[i]-1]
    contests_held_day[t_list[i]-1] = i + 1
    for j in range(26):
        S -= c_list[j] * ((i+1) - contests_held_day[j])
    print(max(S, 0))