結果
問題 | No.1542 ぽんぽんぽん ぽんぽんぽんぽん ぽんぽんぽん |
ユーザー | googol_S0 |
提出日時 | 2021-06-06 18:13:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 658 bytes |
コンパイル時間 | 459 ms |
コンパイル使用メモリ | 87,320 KB |
実行使用メモリ | 848,696 KB |
最終ジャッジ日時 | 2023-08-15 00:19:20 |
合計ジャッジ時間 | 4,855 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
76,136 KB |
testcase_01 | AC | 91 ms
76,248 KB |
testcase_02 | AC | 100 ms
76,788 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | MLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
N=int(input()) S=input() INF=-(10**9) DP=[[[[INF]*(N+1) for i in range(N+1)] for k in range(3)] for j in range(N+1)] DP[0][0][0][0]=0 for i in range(N): for l in range(3): for j in range(N): for k in range(N): if S[i]=='p': DP[i+1][l][j+1][k]=max(DP[i+1][l][j+1][k],DP[i][l][j][k]) elif S[i]=='o': if j: DP[i+1][l][j-1][k+1]=max(DP[i+1][l][j-1][k+1],DP[i][l][j][k]) else: if k: x=min(l+(j==(k-1)==0),2) DP[i+1][x][j][k-1]=max(DP[i+1][x][j][k-1],DP[i][l][j][k]+1) DP[i+1][l][j][k]=max(DP[i+1][l][j][k],DP[i][l][j][k]) print(max(-1,DP[N][2][0][0]-2))