codeforces-scrape

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

41B.md (1179B)


      1 Source: https://codeforces.com/problemset/problem/41/B
      2 
      3 B. Martian Dollar
      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 One day Vasya got hold of information on the Martian dollar course in bourles for the next *n* days. The buying prices and the selling prices for one dollar on day *i* are the same and are equal to *a**i*. Vasya has *b* bourles. He can buy a certain number of dollars and then sell it no more than once in *n* days. According to Martian laws, one can buy only an integer number of dollars. Which maximal sum of money in bourles can Vasya get by the end of day *n*?
     22 
     23 Input
     24 
     25 The first line contains two integers *n* and *b* (1 ≤ *n*, *b* ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains *n* integers *a**i* (1 ≤ *a**i* ≤ 2000) — the prices of Martian dollars.
     26 
     27 Output
     28 
     29 Print the single number — which maximal sum of money in bourles can Vasya get by the end of day *n*.
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 2 4  
     37 3 7
     38 ```
     39 
     40 Output
     41 
     42 ```
     43 8
     44 ```
     45 
     46 Input
     47 
     48 ```
     49 4 10  
     50 4 3 2 1
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 10
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 4 10  
     63 4 2 3 1
     64 ```
     65 
     66 Output
     67 
     68 ```
     69 15
     70 ```