codeforces-scrape

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

435A.md (1469B)


      1 Source: https://codeforces.com/problemset/problem/435/A
      2 
      3 A. Queue on Bus Stop
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand in queue by groups.
     22 
     23 The bus stop queue has *n* groups of people. The *i*-th group from the beginning has *a**i* people. Every 30 minutes an empty bus arrives at the bus stop, it can carry at most *m* people. Naturally, the people from the first group enter the bus first. Then go the people from the second group and so on. Note that the order of groups in the queue never changes. Moreover, if some group cannot fit all of its members into the current bus, it waits for the next bus together with other groups standing after it in the queue.
     24 
     25 Your task is to determine how many buses is needed to transport all *n* groups to the dacha countryside.
     26 
     27 Input
     28 
     29 The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 100). The next line contains *n* integers: *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ *m*).
     30 
     31 Output
     32 
     33 Print a single integer — the number of buses that is needed to transport all *n* groups to the dacha countryside.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 4 3  
     41 2 3 2 1
     42 ```
     43 
     44 Output
     45 
     46 ```
     47 3
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 3 4  
     54 1 2 1
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 1
     61 ```