#2625. 找零
找零
Description
有一台自动售票机,每张票卖 <math xmlns="http://www.w3.org/1998/Math/MathML">5 元。售票机可以接受 <math xmlns="http://www.w3.org/1998/Math/MathML">5 元、<math xmlns="http://www.w3.org/1998/Math/MathML">10 元、<math xmlns="http://www.w3.org/1998/Math/MathML">20元的纸币。接受大面额纸币时,若没有足够的零钱,售票机将拒绝售票并将纸币退还给客户,若有零钱足够,售票机必须出票并且找零。
一开始,售票机里没有任何零钱。
每位客户只买一张票也只会塞一张纸币。按照购票顺序,给定售票机收到的 <math xmlns="http://www.w3.org/1998/Math/MathML">n 张纸币的面额。请统计售货机最多能够卖出多少张票。
Input Format
第一行:单个整数 <math xmlns="http://www.w3.org/1998/Math/MathML">n第二行:<math xmlns="http://www.w3.org/1998/Math/MathML">n 个整数表示 <math xmlns="http://www.w3.org/1998/Math/MathML">n 名客户分别塞入的纸币面额,保证只能是 <math xmlns="http://www.w3.org/1998/Math/MathML">5、<math xmlns="http://www.w3.org/1998/Math/MathML">10、<math xmlns="http://www.w3.org/1998/Math/MathML">20 中的一个。
Output Format
单个整数:表示售票机卖出的最多票数。8
10 5 5 5 10 10 20 20
6
Hint
说明:
由于没有零钱,无法把票卖给第一个人和最后一个人
1≤n≤50,000