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 random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])*(d-last_d[i]+1)/2
        
    return int(score - sum)


def main():
    D = int(input())

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

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

    sche = []
    for i in range(D):
        x = int(input())
        sche.append(x)
    
    last_d = [0 for i in range(26)]
    score = 0
    
    for i in range(D):
        score += s[i][sche[i]-1]
        last_d[sche[i]-1] = i+1
        score = down_score(i+1, c, last_d, score)
        print(score)
        
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
    add = list(map(int, readline().split()))
    s.append(add)

#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)

for i in range(d):
    t = int(readline()) - 1
    up = s[day][t]
    count += 1
    count[t] = 0
    sub = map(mul, count, c)
    satisfy += (up - sum(sub))

    # satisfy
    print(satisfy)

Submission status: Wrong Answer

Solution code:

def read_input():
    D = int(input())
    C = input().split()
    C = [int(i) for i in C]
    S = [list(map(int, input().split())) for _ in range(D)]
    T = [int(input()) for _ in range(D)]
    return D, C, S, T


def scoring(S, D, T, C):
    res = []
    last = [0 for _ in range(26)]
    final = 0
    for i in range(D):
        dec = 0
        last[T[i] - 1] = i
        for j in range(26):
            dec += C[j] * (i - last[j] + 1)
        final += S[i][T[i] - 1] - dec
        res.append(final)
    return res


D, C, S, T = read_input()
res = scoring(S, D, T, C)
for x in res:
    print(x)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
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)]
x=[[0]for _ in range(26)]
ans=0
for i in range(d):
  v=t[i]-1
  ans+=s[i][v]-c[v]*(i-x[v][-1]+1)*(i-x[v][-1])//2
  x[v].append(i+1)
for i in range(26):
  ans-=c[i]*(d+1-x[i][-1])*(d-x[i][-1])//2
  x[i].append(d+1)
print(ans)

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

contest = [0 for _ in range(26)]
ans = 0

for i in range(D):
    t = int(input())
    contest[t-1] += i+1
    ans += S[i][t-1]
    for j, con in enumerate(contest):
        if con:
            ans -= C[j]*(i+1-con)
        else:
            ans -= C[j]*(i+1)
    print(ans)

Submission status: Wrong Answer

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


v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
    sum += s[i][t[i]-1]
    last[i][t[i]-1] = i+1
    for j in range(26):
        sum -= c[j] * ( (i+1) - last[i][j] )
    v[i] = sum

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    D = NI()
    C = NLI()
    S = [NLI() for _ in range(D)]
    #T = [NI() - 1 for _ in range(D)]
    T = []
    last = [0]*26
    conf = 0
    for i in range(D):
        idx, s = argmax(S[i])
        T.append(idx)
        conf += s
        last[idx] = i+1
        for a in range(26):
            conf -= C[a] * (i+1 - last[a])
        print(conf)


def argmax(A):
    A = [[i, a] for i, a in enumerate(A)]
    A.sort(key=lambda x: x[1], reverse=True)
    return A[0]


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(date, LastDay, type, score):
  res = score
  res += s[date-1][type-1]
  for i in range(26):
    if i == type-1:
      continue
    res -= (date - LastDay[i]) *c[i]
  return res

D = I()
c = IL()
s = [IL() for i in range(D)]
ans = [I() for i in range(D)]

LastDay = [0]*26
score = 0
for d in range(D):
  score = tami(d+1, LastDay, ans[d], score)
  LastDay[ans[d]-1] = d+1
  print(max(0, 10**6 + score))

Submission status: Wrong Answer

Solution code:
import random
from copy import deepcopy

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

def min_max(l):
    l_min = min(l)
    l_max = max(l)
    return [1+(i - l_min) / (l_max - l_min) for i in l]

dd = [max(s[i]) for i in range(d)]
qq = min_max(c)
dd = min_max(dd)

ddd = [i for i in range(d)]
qqq = [i for i in range(26)]

ans = []
last = [0]*26
for i in range(d):
    ma_po = -10**10
    ma_di = 0
    for j in range(26):
        po = s[i][j]
        for k in range(26):
            if k == j:
                continue
            po -= c[k]*(i+1-last[k])
        if po > ma_po:
            ma_po = po
            ma_di = j
    last[ma_di] = i+1
    ans.append(ma_di+1)

def score(l):
    lastd = [0]*26
    point = 0
    for j,k in enumerate(l):
        kk = k-1
        point += s[j][kk]
        lastd[kk] = j+1
        for l in range(26):
            point -= c[l]*(j+1-lastd[l])
    return point

ma = score(ans)

def random_search():
    global ans,ma
    li = deepcopy(ans)
    D = random.choices(ddd,k=1,weights=dd)[0]
    lin = [p+1 for p in range(26)]
    Q = random.choices(qqq,k=1,weights=qq)[0]
    li[D] = Q+1
    if score(li) > ma:
        ans = deepcopy(li)
        ma = score(li)

for i in range(20000):
    random_search()

for i in ans:
    print(i)

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)]
lastday=[0 for j in range(26)]
points=[0 for i in range(D)]
t=[0 for i in range(D)]
total=[0 for i in range(D)]
# first day
lastday=[lastday[i]+1 for i in range(26)]
bestpoint=0
for i in range(26):
    temp=[con for con in lastday]
    temp[i]=0
    minus=sum([x*y for (x,y) in zip(c,temp)])
    temppoint=s[0][i]-minus
    if bestpoint<temppoint:
        today=i
        bestpoint=temppoint
        minusb=minus
lastday[today]=0
t[0]=today+1
total[0]=s[0][today]-minusb



for days in range(1,D):
    lastday=[lastday[i]+1 for i in range(26)]
    bestpoint=0
    for i in range(26):
        temp=[con for con in lastday]
        temp[i]=0
        minus=sum([x*y for (x,y) in zip(c,temp)])
        temppoint=s[days][i]-minus
        if bestpoint<temppoint:
            today=i
            bestpoint=temppoint
            minusb=minus
    lastday[today]=0
    t[days]=today+1
    total[days]=total[days-1]+s[days][today]-minusb
    
for ts in t:
    print(ts)

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 di in range(1, d + 1):
    ans += s[di - 1][t[di - 1] - 1]
    last[t[di - 1] - 1] = di
    ans -= sum(c[i] * (di - last[i]) for i in range(26))
    print(max(0, ans))

Submission status: Wrong Answer

Solution code:
INF=10**30
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
last=[0]*26
ans=[]
point=0
for i in range(D):
    d=i+1
    res=-INF
    z=-1
    for j in range(26):
        p=s[i][j]
        for k in range(26):
            if k==j:
                continue
            p-=c[k]*(d-last[k])
        res=max(res,p)
        if res==p:
            z=j
    ans.append(z+1)
    last[z]=i+1
    point+=res
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
from math import inf

A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))

L=[0]*(A+1)
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    print(E)

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()) - 1 for _ in range(d)]
ca = [0] * 26 # 放置された不満の数々
dc = 0 # カレントな満足度
dl = [] # 満足度のログ
 
for i in range(1, d + 1):
    dc += s[i - 1][t[i - 1]]
    ca[t[i - 1]] = i
    dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(26)])
    dl.append(dc)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

d = ni()
c = na()
s = []

for i in range(d):
    ss = na()
    s.append(ss)

c = np.array(c) # 満足度の下がりやすさ
s = np.array(s) # i日目jコン
s_t = s.T # iコンj日目
last = np.zeros(26)

# 評価関数
# 得になった分+その日の満足度
# n: 日数, 
def eva(n, cc, ss):
    return (d-n)*cc + 50*ss

score = 0

for i in range(d): # i日目(0-indexed)
    last += 1 # 一日分追加
    tow = c * last # 満足下がる値 
    sc = -100000
    M = -1
    for j in range(26):
        k = eva(i, tow[j], s[i][j])
        if sc < k:
            sc = k
            M = j
    last[M] = 0
    score -= np.dot(c,last)
    score += s[i][M]
    print(M+1)

Submission status: Wrong Answer

Solution code:
D = int(input())
clist = list(map(int, input().split()))
slist = [list(map(int, input().split())) for _ in range(D)]
tlist = [int(input()) for _ in range(D)]
zlist = []
ans = 0
'''
print(sum(clist))
print('--------------')
print(slist[0][0])
print(slist[1][16])
print(clist[16])

print('--------------')
'''
for i in range(D):
  #print(slist[i],tlist[i]-1)
  zlist.append(clist[tlist[i]-1] * (i+1))
  ans += slist[i][tlist[i]-1] - ((i+1) * sum(clist)) + sum(zlist)
  print(ans)

Submission status: Wrong Answer

Solution code:

import numpy as np

D=int(input())
C=np.array(list(map(int,input().split())))
P=C.copy()
minus_list=C.copy()
S=[]
S_sa=[]
sa=[]
for i in range(D):
    s=np.array(list(map(int,input().split())))
    sa=s-minus_list
    S_sa.append(sa)
    S.append(s)
    sama=max(sa)
    for j in range(26):
        if sama==sa[j]:
            minus_list[j]=0
    minus_list+=C
for i in range(D):
    t=int(input())
    P[t-1]=0
    ans=S[i][t-1]-sum(P)
    P+=C
    print(ans)

Submission status: Wrong Answer

Solution code:
D=int(input())
C=list(map(int,input().split()))
import sys
S=list()
for i in range(D):
  S.append(list(map(int,input().split())))
t=list()
for i in range(D):
  t.append(int(input()))

M=0
di=[0]*26
for d in range(D):
  for i in range(26):
    if i==t[d]-1:
      di[i]=0
    else:
      di[i]+=1
  M+=S[d][t[d]-1]
  for i in range(26):
    M-=C[i]*(d+1-di[i])
  print(M)

Submission status: Wrong Answer

Solution code:
D = int(input())
c_list = 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)]
x = 0; y = 0; z = 0; emp1 = []; emp2 = []; emp3 = []
for d in range(1,D+1):
    x += s_list[d-1][t_list[d-1]-1]
    emp2.append(x)
for d in range(1,D+1):
    emp1.append(t_list[d-1])
    for j in range(0,26):
        if j+1 in emp1:
            emp1.reverse()
            z += c_list[j] * (d-((len(emp1)-1-emp1.index(j+1)) + 1))
            emp1.reverse()
        else:
            z += c_list[j] * d
    y -= z
    emp3.append(y)
xy = [a+b for (a,b) in zip (emp2,emp3)]
[print(i) for i in xy]

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

tL = []
for i in range(D):
    tL.append(max(S))

for t in tL:
    print(t)

Submission status: Wrong Answer

Solution code:
d = int(input())
c = list(map(int, input().split()))
sc = sum(c)
sl = []
for i in range(d):
  s = list(map(int, input().split()))
  sl.append(s)
tl = []
for i in range(d):
  t = int(input())
  tl.append(t - 1)
vdl = []
ld = 0
lvd = 0
lastd = [0] * 26
for i in range(d):
  for j in range(26):
    if j == tl[i]:
      lastd[j] += 1
    else:
      lastd[j] = 0
for i in range(d):
  td = int(tl[i])
  cd = c[td]
  sd = sl[i]
  vd = sd[td] - cd * (i - lastd[td])
  ld = i
  lvd += vd
  vdl.append(lvd)
for i in range(d):
  print(vdl[i])

Submission status: Wrong Answer

Solution code:
import random

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


class Scorer:

    def __init__(self, c, s):
        n_cty = len(c)
        self.c = c  # (#cty,)
        self.s = s  # (D, #cty)
        self.elapsed_time = [0] * n_cty

        self.score = 0

    def check_updated_score(self, d, cty):
        elapsed_time = self.elapsed_time[:]

        # update elapsed time
        for cty_ in range(len(elapsed_time)):
            if cty_ == cty:
                elapsed_time[cty_] = 0
            else:
                elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in range(len(elapsed_time)):
            cur_score -= self.c[cty_] * elapsed_time[cty_]
        return self.score + cur_score

    def update_score(self, d, cty):
        elapsed_time = self.elapsed_time[:]

        # update elapsed time
        for cty_ in range(len(elapsed_time)):
            if cty_ == cty:
                elapsed_time[cty_] = 0
            else:
                elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in range(len(elapsed_time)):
            cur_score -= self.c[cty_] * elapsed_time[cty_]

        self.score += cur_score
        self.elapsed_time = elapsed_time
        return self.score


scorer = Scorer(C, S)
T = []
for d in range(D):
    best_cty = -1
    best_score = -1
    for cty_ in range(26):
        cur_score = scorer.check_updated_score(d, cty_)
        if best_score < cur_score:
            best_cty = cty_
            best_score = cur_score
    scorer.update_score(d, best_cty)
    T.append(best_cty)

N_REPLACE = 5
N_ITER = 100
EPS = 0.5
ATT = 0.95

best_score = -1
for _ in range(N_ITER):
    scorer = Scorer(C, S)
    T_ = T[:]

    # replace N elements
    for i in range(N_REPLACE):
        T_[random.randint(0, D - 1)] = random.randint(1, 26)

    for d in range(D):
        cty = T_[d] - 1
        scorer.update_score(d, cty)
    if best_score <= scorer.score:
        best_score = scorer.score
        T = T_
    elif random.random() < EPS:
        best_score = scorer.score
        T = T_
    EPS *= ATT

# for t in T:
#     print(t)

print(best_score)

Submission status: Wrong Answer

Solution code:
D = int(input())
clist = list(map(int, input().split()))
slist = [list(map(int, input().split())) for _ in range(D)]
tlist = [int(input()) for _ in range(D)]

ans = 0
'''
print(sum(clist))
print('--------------')
print(slist[0][0])
print(slist[1][16])
print(clist[16])

print('--------------')
'''
for i in range(D):
  #print(slist[i],tlist[i]-1)
  ans += slist[i][tlist[i]-1] - ((i+1) * sum(clist)) + clist[tlist[i]-1]
  print(ans)

Submission status: Wrong Answer

Solution code:
D=int(input())
c=[int(x) for x in input().split()]
s=[[0]*i for i in range(D)]
t=[]
last_d=[0]*26
for i in range(D):
  s[i]=[int(x) for x in input().split()]
for i in range(D):
  t.append(int(input()))

v=0
C=sum(c)
print(C)
for i in range(D):
  a=0
  for j in range(26):
    if j!=t[i]-1:
      n=i+1-last_d[j]
      a+=c[j]*n
  v=v+s[i][t[i]-1]-a
  print(v)
  last_d[t[i]-1]=i+1

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())
clist = list(map(int, input().split()))
slist = [list(map(int, input().split())) for _ in range(D)]
tlist = [int(input()) for _ in range(D)]

ans = 0

print(sum(clist))
print('--------------')
print(slist[0][0])
print(slist[1][16])
print(clist[16])

print('--------------')

for i in range(D):
  #print(slist[i],tlist[i]-1)
  ans += slist[i][tlist[i]-1] - ((i+1) * sum(clist)) + clist[tlist[i]-1]
  print(ans)

Submission status: Wrong Answer

Solution code:
s = [input() for i in range(2)]
l0 = int(s[0])
l1 = list(map(int, s[1].split()))
l1all = sum(l1)
t = [input() for i in range(l0)]
for i in range(l0):
    l2 = list(map(int, t[i].split()))
sowa = 0
u = [input() for i in range(l0)]
for i in range(l0):
    l3 = int(u[i])
    #print("l3:",l3,",l2[",l3-1,"]:",l2[l3-1],",l1all:",l1all,",l1[",l3-1,"]:",l1[l3-1])
    sowa+=l2[l3-1]
    sowa-=l1all
    sowa+=l1[l3-1]
    #print("l3:",l3-1,",l2[l3]:",l2[l3-1],",l1all:",l1all,",l1[l3]:",l1[l3-1])
    print(sowa)

Submission status: Wrong Answer

Solution code:
#<I to HC>
d = int(input())
c = list(map(int,input().split()))
ls = []
for i in range(d):
    s = list(map(int,input().split()))
    ls.append(s)
#print(ls)
ls2=[]
for j in range(d):
    t = int(input())
    ls2.append(t)
ans = 0
x = []
for k in range(d):
    ans += ls[k][ls2[k] - 1]
    x.append(ls[k][ls2[k] - 1])
    #print(ans)
    for y in c:
        if i in x:
            ans -= c[ls2[k] - 1]*(k - x.index(i) + 1)
        else:
            ans -= (k + 1) *  y
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

last = [0] * 26

ans = 0
max_M = 0
tmp_t = 0
t = []

for i in range(D):
    # リストを読む
    s = list(map(int, input().split()))
    # 1日経つ
    last = list(map(lambda x: x + 1, last))
    # マイナスの合計を出す
    minus = 0
    for x in range(26):
        minus = minus + (c[x] * last[x])
    # 一番高い結果の判定
    max_M = 0
    for y in range(26):
        if max_M < s[y] + (c[y] * last[y]) - minus:
            max_M = s[y] + (c[y] * last[y]) - minus
            tmp_t = y                                                               
            print(max_M)
    # 判定後
    t.append(tmp_t + 1  )
    last[tmp_t] = 0

print(*t, sep='\n')

Submission status: Wrong Answer

Solution code:
import copy
D = int(input())
c = list(map(int, input().split()))
s = []
for _ in range(D):
  s.append(list(map(int, input().split())))
t = []
for _ in range(D):
  t.append(int(input()))
u = [] # last(d,i)
x = [0] * 26
u.append(x)
for i in range(D):
  v = copy.deepcopy(u)
  y = v[-1]
  y[t[i]-1] = i+1
  u.append(y)
del u[0]
print(D)
print(c)
print(s)
print(t)
print(u)
ans = 0
for i in range(D):
  ans += s[i][t[i]-1]
  for j in range(26):
    ans -= c[j] * ((i+1) - u[i][j]) 
  print(ans)

Submission status: Wrong Answer

Solution code:
D = int(input())
c_list = list(map(int, input().split()))

LD=[0] * 26
manzoku = 0

for i in range(D):
  # ある日の満足度を求める
  d = list(map(int, input().split()))
  
  # ある日の最大の値を求める
  M = max(d)
  
  genshou = 0
  for j in range(26):
    if j != d.index(M):
      LD[j] += 1
      genshou -= c_list[j] * LD[j]
    else:
      LD[j] = 0
      
  manzoku += M + genshou
  
  print(manzoku)

Submission status: Wrong Answer

Solution code:
D=int(input())
*c,=map(int,input().split())

ci=[(c[i-1],i) for i in range(1,27)]
ci=[(0,0)]+sorted(ci,reverse=True)

last=[[0]*27]*(D+1)
S=[[0]*27]*(D+1)
DP=[[0]*27]*(D+1)
T=[0]*(D+1)

for d in range(1,D+1):
    *S[d],=map(int,input().split())
    S[d]=[0]+S[d]
    
for d in range(1,D+1):
  T[d] = int(input())

def do_id(i,d):
    dn=0
    for k in range(1,27):
      if k!=i:
        dn += ci[k][0]*(d-last[d][k])
    return S[d][i]-dn

Satis=0  
for d in range(1,D+1):
  Satis+=do_id(T[d],d)
  print(Satis)
  
def cal():  
  for d in range(1,D+1):
    mxid=0
    mxi,mxd=0,0
    for i in range(1,27):
      doid=do_id(i,d)
      if doid>mxid:
           mxid=doid
           mxi,mxd=i,d
    DP[mxd][mxi]=mxid             
    last[mxd][mxi]=d
  print(DP)

Submission status: Wrong Answer

Solution code:
import numpy as np
D=int(input())

c_list=list(map(int,input().split()))
c_list=np.array(c_list)
c_ll=np.array([0]*26)

d_list=[]
for i in range(D):
    dl=list(map(int,input().split()))
    d_list.append(np.array(dl))

# score
score=0

#expect
exp=[0]*26
for d in range(D):
    c_ll+=1
    for i in range(26):
        exp[i]+=d_list[d][i]
        c_ll2=c_ll
        c_ll2[i]=0
        exp[i]-=sum(c_list*c_ll)

    j=exp.index(max(exp))
    c_ll[j]=0
    print(j+1)

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+1)
  print(index+1)

Submission status: Wrong Answer

Solution code:
import random
from copy import deepcopy

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

ans = []

for i in range(d):
    ans.append(s[i].index(max(s[i]))+1)

def score(l):
    lastd = [0]*26
    point = 0
    for j,k in enumerate(l):
        kk = k-1
        point += s[j][kk]
        lastd[kk] = j+1
        for l in range(26):
            point -= c[l]*(j+1-lastd[l])
    return point

ma = score(ans)

def random_search():
    global ans,ma
    li = deepcopy(ans)
    D = random.randrange(0,d,1)
    Q = random.randrange(0,26,1)
    li[D] = Q+1
    if score(li) > ma:
        ans = deepcopy(li)
        ma = score(li)

for i in range(10000):
    random_search()

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
lastday=[-1]*26
def last(d):
  sum=0
  for i in range(26):
    sum+=c[i]*(d-lastday[i])
  return sum
def myFunc(i,Score,depth):
  tmp_score=Score
  tmp_max_choice=0
  tmp_score-=last(i)
  tmp_max_score=tmp_score
  for k,j in enumerate(s[i]):
    if tmp_max_score<tmp_score+j+c[k]*(i-lastday[k]):
      tmp_max_choice=k
      tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
  return tmp_max_score,tmp_max_choice
  

D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
Score=0
for i in range(D):
  score,choice=myFunc(i,Score,1)
  Score=score
  lastday[choice]=i
  print(choice+1)

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+1)
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)
print(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)]
lastday = [0]*26
dayscore = 0
finalscore = 0

for day in range(1,d+1):
    lastday[t[day-1]-1] = day
    score = 0
    for i in range(26):
        dayscore = s[day-1][i]
        for j in range(26):
            dayscore -= c[j]*(day-lastday[j])
        if score < dayscore:
            score = dayscore
    finalscore += score
    print(finalscore)

Submission status: Wrong Answer

Solution code:
import random


d = int(input())
c = list(map(int,input().split()))
s = []

class field:
    def __init__(self):
        self.ans = [-1 for i in range(365)]
        self.last = [-1 for i in range(26)]


    def score_day(self,day,type):
        inc = s[day][type]
        dec = 0
        for i in range(26):
            dec += c[i]*(day-self.last[i])

        return  inc-dec


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

best_score = 0
alloc = []

F = field()
ans = 0
good = []
childs = 50
for day in range(d):
    if day == 0:
        tp_scores = []
        for j in range(25):
            prob = j
            befl = F.last[prob]
            F.last[prob] = day
            sc = F.score_day(day, prob)
            tp_scores.append([-sc, j,F.last.copy(),str(j)])

            F.last[prob] = befl

        tp_scores.sort()
        good = tp_scores
    else:
        tp_scores = []
        for i in range(min(childs,len(good))):
            befs = good[i][0]
            befp = good[i][1]
            befl = good[i][2]
            befa = good[i][3]
            F.last = befl
            for j in range(25):
                prob = j
                bt = F.last[prob]
                F.last[prob] = day
                sc = F.score_day(day,prob)
                tp_scores.append([befs-sc,j,F.last.copy(),befa+","+str(j)])

                F.last[prob] = bt

        tp_scores.sort()
        good = tp_scores[:childs]

# print(good[0])


# for g in good:
#     tp = 0
#     root = list(map(int,g[-1].split(",")))
#     F = field()
#     for i in range(len(root)):
#         F.ans[i] = root[i]
#         F.last[root[i]] = i
#         tp += F.score_day(i,root[i])
#     print(root,tp)

# print("bestscore:"+str(best_score))

root = map(int,good[0][-1].split(","))

for r in root:
    print(r+1)