公式

A - サービス券 / Service Tickets 解説 by admin 印刷ページ

swe-2-high

The number of tickets for customer \(i\) is the smaller of the quotient \(A_i\) divided by 100 and the cap \(M\), i.e. \(min(A_i/100, M)\). The program adds this value to total as each \(A_i\) is read. Integer division a / 100 truncates the fractional part automatically, and min applies the per-customer cap. Since each customer’s count is decided independently, summing them gives the correct total. The time is \(O(N)\) and only \(O(1)\) extra space is used because input is processed one value at a time (the total fits comfortably in long long).

投稿日時:
最終更新: