結果

問題 No.1288 yuki collection
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-17 08:03:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 1,110 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 77,908 KB
最終ジャッジ日時 2023-10-11 19:50:51
合計ジャッジ時間 7,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,208 KB
testcase_01 AC 74 ms
71,204 KB
testcase_02 AC 74 ms
71,188 KB
testcase_03 WA -
testcase_04 AC 76 ms
70,968 KB
testcase_05 AC 74 ms
71,248 KB
testcase_06 WA -
testcase_07 AC 74 ms
71,140 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 120 ms
77,216 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 133 ms
77,428 KB
testcase_37 WA -
testcase_38 AC 126 ms
76,948 KB
testcase_39 AC 124 ms
77,028 KB
testcase_40 AC 80 ms
76,268 KB
testcase_41 AC 75 ms
71,176 KB
testcase_42 AC 74 ms
71,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=list(input())
v=list(map(int,input().split()))
taken=[0]*n
pre=-1
ans=0
while pre!=ans:
  y=[0,-1]
  yu=[0,-1,-1]
  yuk=[0,-1,-1,-1]
  yuki=[0,-1,-1,-1,-1]
  pre=ans
  for i in range(n):
    if taken[i]==1:continue
    if s[i]=='y':
      if y[0]<v[i]:
        y=[v[i],i]
    elif s[i]=='u' and y[0]>0:
      if yu[0]<v[i]+y[0]:
        yu=[v[i]+y[0],y[1],i]
    elif s[i]=='k' and yu[0]>0:
      if yuk[0]<v[i]+yu[0]:
        yuk=[v[i]+yu[0],yu[1],yu[2],i]
    elif s[i]=='i' and yuk[0]>0:
      if yuki[0]<v[i]+yuk[0]:
        yuki=[v[i]+yuk[0],yuk[1],yuk[2],yuk[3],i]
  if yuki[0]>0:
    ans+=yuki[0]
    taken[yuki[1]]=1
    taken[yuki[2]]=1
    taken[yuki[3]]=1
    taken[yuki[4]]=1
print(ans)

0