---
# System prepended metadata

title: h035 夜市

---

# h035 夜市
## 題目連結
[h035](https://zerojudge.tw/ShowProblem?problemid=h035)
## 解題想法
* 正常讀資料
* 額外創造兩個陣列紀錄板子是否被打過和板子現在的狀態
## 程式碼
```python=
#input
n = int(input())
data = [int(i) for i in input().split()]
up = ['up' for i in range(9)] #記錄板子的狀態(是否立起或倒下秒數)
isHit = [False for i in range(9)] #紀錄板子是否被打過
score = 0
isprint = False #紀錄是否perfect(有perfect就不print分數)

#process
for i in range(n):
    #所有板子秒數增加並且如果需要就立起板子
    for j in range(len(up)):
        if type(up[j]) == int:
            up[j] += 1
        if up[j] == 12: up[j] = 'up'
    #小佳投球
    now = data[i] - 1
    if now != -2 and up[now] == 'up':
        up[now] = 0
        if isHit[now] == False:
            isHit[now] = True
            score += (now+1)
    #判斷是否perfect
    if up.count('up') == 0:
        print('perfect')
        isprint = True
        break

#output
if isprint == False:
    print(score)

```