QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18396. 討厭零錢

統計

jwpassion1 找出了幾張不再使用的舊交通卡,打算將裡面的餘額退款成現金。jwpassion1 除了在玩需要 $500$ 韓元硬幣的節奏遊戲外,平時幾乎不會用到現金。然而,他退款得到的金額除以 $500$ 後,餘數恰好為 $490$,導致他手邊多了 $9$ 個毫無用處的硬幣,讓他感到非常困擾。因此,他決定以後要小心,避免產生不必要的硬幣。

具體來說,退款交通卡時必須遵守以下規則:

  • 餘額在 $20\,000$ 韓元以上的交通卡無法退款。
  • 退款手續費為 $500$ 韓元。也就是說,第 $i$ 張交通卡的退款金額為 精確的 $A_i - 500$ 韓元。若交通卡的餘額 $A_i \leq 500$,則退款並不划算,因此無法退款。
  • 所有退款金額的總和必須能被 $500$ 整除。

給定 jwpassion1 持有的交通卡數量以及每張交通卡的餘額,請計算他能退款得到的最大總金額。

輸入格式

第一行輸入一個非負整數 $N$,代表交通卡的數量。($0\leq N\leq 100\,000$)

從第二行開始,共有 $N$ 行,每行輸入一個整數 $A_i$,代表第 $i$ 張交通卡的餘額。($0\leq A_i\leq 100\,000$;$A_i$ 為 $10$ 的倍數)

若 $N$ 為 $0$,則輸入僅包含第一行。

輸出格式

輸出可以退款得到的最大總金額。

若無法進行任何退款,則輸出 $0$。

範例

輸入格式 1

5
1000
520
450
19500
20000

輸出格式 1

19500

輸入格式 2

4
600
1100
850
950

輸出格式 2

1500

輸入格式 3

4
990
990
990
990

輸出格式 3

0

輸入格式 4

0

輸出格式 4

0

說明

jwpassion1 實際上擁有退款後得到的 $490$ 韓元。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.