codeforces-scrape

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

1121C.md (3636B)


      1 Source: https://codeforces.com/problemset/problem/1121/C
      2 
      3 C. System Testing
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.
     22 
     23 There are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one solution on one test takes $1$ second. The solutions are judged in the order from $1$ to $n$. There are $k$ testing processes which test solutions simultaneously. Each of them can test at most one solution at a time.
     24 
     25 At any time moment $t$ when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id $i$, then it is being tested on the first test from time moment $t$ till time moment $t + 1$, then on the second test till time moment $t + 2$ and so on. This solution is fully tested at time moment $t + a_i$, and after that the testing process immediately starts testing another solution.
     26 
     27 Consider some time moment, let there be exactly $m$ fully tested solutions by this moment. There is a caption "System testing: $d$%" on the page with solutions, where $d$ is calculated as
     28 
     29 $$d = round\left(100\cdot\frac{m}{n}\right),$$
     30 
     31 where $round(x) = \lfloor{x + 0.5}\rfloor$ is a function which maps every real to the nearest integer.
     32 
     33 Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test $q$, and the caption says "System testing: $q$%". Find the number of interesting solutions.
     34 
     35 Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter.
     36 
     37 Input
     38 
     39 The first line contains two positive integers $n$ and $k$ ($1 \le n \le 1000$, $1 \le k \le 100$) standing for the number of submissions and the number of testing processes respectively.
     40 
     41 The second line contains $n$ positive integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 150$), where $a_i$ is equal to the number of tests the $i$-th submission is to be run on.
     42 
     43 Output
     44 
     45 Output the only integer — the number of interesting submissions.
     46 
     47 Examples
     48 
     49 Input
     50 
     51 ```
     52 2 2
     53 49 100
     54 ```
     55 
     56 Output
     57 
     58 ```
     59 1
     60 ```
     61 
     62 Input
     63 
     64 ```
     65 4 2
     66 32 100 33 1
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 2
     73 ```
     74 
     75 Input
     76 
     77 ```
     78 14 5
     79 48 19 6 9 50 20 3 42 38 43 36 21 44 6
     80 ```
     81 
     82 Output
     83 
     84 ```
     85 5
     86 ```
     87 
     88 Note
     89 
     90 Consider the first example. At time moment $0$ both solutions start testing. At time moment $49$ the first solution is fully tested, so at time moment $49.5$ the second solution is being tested on the test $50$, and the caption says "System testing: $50$%" (because there is one fully tested solution out of two). So, the second solution is interesting.
     91 
     92 Consider the second example. At time moment $0$ the first and the second solutions start testing. At time moment $32$ the first solution is fully tested, the third solution starts testing, the caption says "System testing: $25$%". At time moment $32 + 24.5 = 56.5$ the third solutions is being tested on test $25$, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment $32 + 33 = 65$, the fourth solution is fully tested at time moment $65 + 1 = 66$. The captions becomes "System testing: $75$%", and at time moment $74.5$ the second solution is being tested on test $75$. So, this solution is also interesting. Overall, there are two interesting solutions.