codeforces-scrape

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

44B.md (1683B)


      1 Source: https://codeforces.com/problemset/problem/44/B
      2 
      3 B. Cola
      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 To celebrate the opening of the Winter Computer School the organizers decided to buy in *n* liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly *a* bottles 0.5 in volume, *b* one-liter bottles and *c* of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well).
     22 
     23 Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly *n* liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer.
     24 
     25 All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind.
     26 
     27 Input
     28 
     29 The first line contains four integers — *n*, *a*, *b*, *c* (1 ≤ *n* ≤ 10000, 0 ≤ *a*, *b*, *c* ≤ 5000).
     30 
     31 Output
     32 
     33 Print the unique number — the solution to the problem. If it is impossible to buy exactly *n* liters of cola, print 0.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 10 5 5 5
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 9
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 3 0 0 2
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 0
     59 ```