codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

349A.md (1190B)


      1 Source: https://codeforces.com/problemset/problem/349/A
      2 
      3 A. Cinema Line
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 The new "Die Hard" movie has just been released! There are *n* people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the tickets strictly in the order people follow in the line?
     22 
     23 Input
     24 
     25 The first line contains integer *n* (1 ≤ *n* ≤ 105) — the number of people in the line. The next line contains *n* integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line.
     26 
     27 Output
     28 
     29 Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO".
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 4  
     37 25 25 50 50
     38 ```
     39 
     40 Output
     41 
     42 ```
     43 YES
     44 ```
     45 
     46 Input
     47 
     48 ```
     49 2  
     50 25 100
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 NO
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 4  
     63 50 50 25 25
     64 ```
     65 
     66 Output
     67 
     68 ```
     69 NO
     70 ```